Skip to content

Commit b13a786

Browse files
trsmith2jgarnier
authored andcommitted
Factor out build logic from Jenkinsfile (#11)
* Factor out build logic from Jenkinsfile PNDA-1918 * Fail fast on unit test failure PNDA-1918
1 parent eecf003 commit b13a786

File tree

4 files changed

+43
-14
lines changed

4 files changed

+43
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [Unreleased]
5+
### Changed
6+
- Externalized build logic from Jenkins to shell script so it can be reused
7+
48
## [0.2.0] 2016-10-21
59
### Added
610
- PNDA-2233 Jupyter notebook plugin added to deployment manager

Jenkinsfile

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,10 @@ node {
1414
checkout([$class: 'GitSCM', branches: [[name: "tags/${version}"]], extensions: [[$class: 'CleanCheckout']]])
1515
}
1616

17-
sh """
18-
cd api
19-
mvn versions:set -DnewVersion=${version}
20-
mvn clean package
21-
"""
17+
sh("./build.sh ${version}")
2218

23-
stage 'Test'
24-
sh '''
25-
cd api/src/main/resources
26-
pylint_wrapper.py 10
27-
nosetests test_*.py
28-
'''
29-
30-
stage 'Deploy'
31-
build job: 'deploy-component', parameters: [[$class: 'StringParameterValue', name: 'branch', value: env.BRANCH_NAME],[$class: 'StringParameterValue', name: 'component', value: "deployment-manager"],[$class: 'StringParameterValue', name: 'release_path', value: "platform/releases"],[$class: 'StringParameterValue', name: 'release', value: "${workspace}/api/target/deployment-manager-${version}.tar.gz"]]
19+
stage 'Deploy'
20+
build job: 'deploy', parameters: [[$class: 'StringParameterValue', name: 'artifacts_path', value: "${workspace}/pnda-build"]]
3221

3322
emailext attachLog: true, body: "Build succeeded (see ${env.BUILD_URL})", subject: "[JENKINS] ${env.JOB_NAME} succeeded", to: "${env.EMAIL_RECIPIENTS}"
3423

api/src/main/resources/test_package_parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,5 @@ def test_generate_properties(self):
143143
}
144144
}
145145
self.assertEqual(parser.properties_from_metadata(metadata), expected_properties)
146+
147+

build.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
#
3+
# Please check pnda-build/ for the build products
4+
5+
VERSION=${1}
6+
7+
function error {
8+
echo "Not Found"
9+
echo "Please run the build dependency installer script"
10+
exit -1
11+
}
12+
13+
echo -n "Apache Maven 3.0.5: "
14+
if [[ $(mvn -version 2>&1) == *"Apache Maven 3.0.5"* ]]; then
15+
echo "OK"
16+
else
17+
error
18+
fi
19+
20+
mkdir -p pnda-build
21+
22+
BASE=${PWD}
23+
24+
cd ${BASE}/api/src/main/resources
25+
nosetests test_*.py
26+
[[ $? -ne 0 ]] && exit -1
27+
28+
cd ${BASE}/api
29+
mvn versions:set -DnewVersion=${VERSION}
30+
mvn clean package
31+
cd ${BASE}
32+
mv api/target/deployment-manager-${VERSION}.tar.gz pnda-build/
33+
sha512sum pnda-build/deployment-manager-${VERSION}.tar.gz > pnda-build/deployment-manager-${VERSION}.tar.gz.sha512.txt
34+

0 commit comments

Comments
 (0)