Skip to content
Permalink
Newer
Older
100644 94 lines (66 sloc) 2.48 KB
1
node('packer') {
2
currentBuild.result = "SUCCESS"
3
Jim Van Fleet
Sep 6, 2016
4
stage 'Checkout'
5
6
checkout scm
7
8
stage 'Appliance build'
9
echo "My Branch is: ${env.BRANCH_NAME}"
10
11
BRANCH_TEST = "${env.BRANCH_NAME}"
12
13
if (BRANCH_TEST=="shibboleth-production"){
14
performBuild("shibboleth")
15
} else if (BRANCH_TEST=="grouper-production"){
16
performBuild("grouper")
17
} else if (BRANCH_TEST=="comanage-production"){
18
performBuild("comanage")
21
}
22
23
def performBuild(String project){
24
try {
25
stage 'Cleanup & Setup'
26
sh "rm -rf output-${project}-*"
27
sh "bin/remove-${project}.sh"
28
sh 'rm -rf builds'
29
sh 'mkdir -p builds'
30
31
withCredentials([[$class: 'FileBinding', credentialsId: 'tier-aws-config', variable: 'FILE']]) {
32
ws {
33
sh 'mkdir -p ~/.aws'
34
sh 'cp $FILE ~/.aws/config'
35
}
38
withCredentials([[$class: 'FileBinding', credentialsId: 'tier-aws-credentials', variable: 'FILE']]) {
39
ws {
40
sh 'mkdir -p ~/.aws'
41
sh 'cp $FILE ~/.aws/credentials'
42
}
45
stage 'Acquire ansible-playbooks'
47
sh 'rm -rf ansible-playbooks'
48
sh 'mkdir -p ansible-playbooks'
49
dir('ansible-playbooks'){
50
git([ url: "https://github.internet2.edu/docker/ansible-playbooks.git",
51
branch: "master", credentialsId: "jenkins-github-access-token" ])
52
}
Mason Packard
Aug 19, 2016
53
54
stage 'Validate'
Mason Packard
Aug 19, 2016
55
Jim Van Fleet
Sep 6, 2016
56
sh "/usr/local/bin/packer validate ${project}-appliance.json"
Mason Packard
Aug 19, 2016
57
58
stage 'Build Appliance'
Mason Packard
Aug 20, 2016
59
Jim Van Fleet
Sep 6, 2016
60
sh "/usr/local/bin/packer build ${project}-appliance.json"
Mason Packard
Aug 20, 2016
61
62
stage 'Sync appliances to S3 bucket'
64
sh "aws s3 sync builds s3://internet2-tier-appliance-us-west-1"
66
stage 'Publish results'
68
sh "bin/perms.sh > results.txt"
70
slackSend color: 'good', message: "BUILD SUCCESS: Appliance build success. ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL} |Open>)"
71
72
slackSend color: 'good', message: readFile('./results.txt')
74
sh "rm results.txt"
75
76
}
78
catch (err) {
79
handleError("BUILD ERROR: There was a problem with ${project} Appliance. ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL} |Open>) \n\n ${err}", "${project}-appliance-centos7-xfs")
Mason Packard
Aug 19, 2016
81
}
82
83
def handleError(String message, String appliance_name){
84
echo "${message}"
85
currentBuild.setResult("FAILED")
86
slackSend color: 'danger', message: "${message}"
87
//step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chris.bynum@levvel.io', sendToIndividuals: true])
89
sh "VBoxManage controlvm ${appliance_name} poweroff"
90
91
sh "VboxManage unregistervm ${appliance_name} --delete"
92
93
sh 'exit 1'
You can’t perform that action at this time.