This repository was archived by the owner on Jun 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
executable file
·94 lines (75 loc) · 2.47 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// author: Zach Crabtree [email protected]
node ("python2.7")
{
// Set path for custom management tools on jenkins
def is_release=(params.create_release)
echo "BUILDTYPE: " + (is_release ? "Release" : "Integration")
env.PATH = "${tool 'ant 1.9.7'}/bin:${env.PATH}"
try {
stage ("Git configuration") {
git branch: 'master', url: 'ssh://[email protected]:7999/aics/aicsimage.git'
}
stage ("Clean") {
sh 'ant -f pipeline/build.xml clean'
}
stage ("Virtual Environment Setup") {
createVirtualEnv()
}
stage ("Prepare Version") {
sh 'manage_python_build.py prepare_release_version'
}
stage ("Build and Publish") {
if (is_release) {
sh 'ant -f pipeline/build.xml publish-release'
}
else {
sh 'ant -f pipeline/build.xml publish-snapshot'
}
}
stage ("Test Report") {
junit 'nosetests.xml'
}
stage ("Tag and Push Version") {
if (is_release) {
sh 'manage_python_build.py tag_and_push_version'
}
}
currentBuild.result = "SUCCESS"
}
catch(e) {
currentBuild.result = "FAILURE"
throw e
}
finally {
deleteVirtualEnv()
notifyBuildOnSlack(currentBuild.result, is_release)
// Email
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: '[email protected]',
sendToIndividuals: true])
}
}
def createVirtualEnv() {
sh 'ant -f pipeline/build.xml venv-setup'
}
def deleteVirtualEnv() {
sh 'ant -f pipeline/build.xml venv-destroy'
}
def notifyBuildOnSlack(String buildStatus = 'STARTED', Boolean is_release) {
// build status of null means successful
buildStatus = buildStatus ?: 'SUCCESS'
buildType = is_release ? 'RELEASE' : 'SNAPSHOT'
// Default values
def colorCode = '#FF0000'
def subject = "${buildStatus} ${buildType}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
def summary = "${subject} (${env.BUILD_URL})"
// Override default values based on build status
if (buildStatus == 'SUCCESS') {
colorCode = is_release ? '#008000' : '#00FF00'
} else {
colorCode = is_release ? '#800000' : '#FF0000'
}
// Send notifications
slackSend (color: colorCode, message: summary)
}