Skip to content
Permalink
Newer
Older
100644 149 lines (106 sloc) 4.15 KB
1
node('packer') {
2
currentBuild.result = "SUCCESS"
3
4
stage 'Appliance build'
5
echo "My Branch is: ${env.BRANCH_NAME}"
6
7
BRANCH_TEST = "${env.BRANCH_NAME}"
8
9
if (BRANCH_TEST=="shibboleth-production"){
10
performBuild("shibboleth")
11
} else if (BRANCH_TEST=="grouper-production"){
12
performBuild("grouper")
13
} else if (BRANCH_TEST=="comanage-production"){
14
performBuild("comanage")
15
}
16
17
}
18
19
def performBuild(String project){
20
try {
21
stage 'Cleanup & Setup'
22
sh "rm -rf output-${project}-*"
23
sh "rm -rf \"/Users/levvel/VirtualBox VMs/${project}-appliance-*\""
24
sh 'rm -rf builds'
25
sh 'mkdir -p builds'
26
27
withCredentials([[$class: 'FileBinding', credentialsId: 'tier-aws-config', variable: 'FILE']]) {
28
ws {
29
sh 'mkdir -p ~/.aws'
30
sh 'cp $FILE ~/.aws/config'
31
}
34
withCredentials([[$class: 'FileBinding', credentialsId: 'tier-aws-credentials', variable: 'FILE']]) {
35
ws {
36
sh 'mkdir -p ~/.aws'
37
sh 'cp $FILE ~/.aws/credentials'
38
}
41
stage 'Checkout'
43
checkout scm
45
stage 'Acquire ansible-playbooks'
47
sh 'mkdir -p ansible-playbooks'
48
dir('ansible-playbooks'){
49
git([ url: "https://github.internet2.edu/docker/ansible-playbooks.git",
50
branch: "{{project}}-production", credentialsId: "jenkins-github-access-token" ])
51
}
Mason Packard
Aug 19, 2016
52
53
stage 'Validate'
Mason Packard
Aug 19, 2016
54
55
sh "/usr/local/bin/packer validate {{project}}-appliance.json"
Mason Packard
Aug 19, 2016
56
57
stage 'Build Appliance'
Mason Packard
Aug 20, 2016
58
59
sh "/usr/local/bin/packer build {{project}}-appliance.json"
Mason Packard
Aug 20, 2016
60
61
stage 'Sync appliances to S3 bucket'
63
sh "aws s3 sync builds s3://internet2-tier-appliance-us-west-1"
64
65
stage 'Publish results'
66
67
sh "bin/perms.sh > results.txt"
69
slackSend color: 'good', message: "BUILD SUCCESS: Shibboleth Appliance build success. ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL} |Open>)"
70
71
slackSend color: 'good', message: readFile('./results.txt')
72
73
sh "rm results.txt"
74
75
}
77
catch (err) {
78
handleError("BUILD ERROR: There was a problem with ${project} Appliance. ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL} |Open>) \n\n ${err}")
79
}
80
} else if (BRANCH_TEST=="grouper-production") {
81
node('packer') {
82
currentBuild.result = "SUCCESS"
83
84
try {
85
stage 'Cleanup & Setup '
86
sh 'rm -rf output-grouper-*'
87
sh 'rm -rf "/Users/levvel/VirtualBox VMs/grouper-appliance-*"'
88
sh 'rm -rf builds'
89
sh 'mkdir -p builds'
90
91
withCredentials([[$class: 'FileBinding', credentialsId: 'our-aws-config', variable: 'FILE']]) {
92
ws {
93
sh 'mkdir -p ~/.aws'
94
sh 'cp $FILE ~/.aws/config'
95
}
96
}
97
98
withCredentials([[$class: 'FileBinding', credentialsId: 'our-aws-credentials', variable: 'FILE']]) {
99
ws {
100
sh 'mkdir -p ~/.aws'
101
sh 'cp $FILE ~/.aws/credentials'
102
}
103
}
104
105
stage 'Checkout'
106
107
checkout scm
108
109
stage 'Acquire ansible-playbooks'
110
111
sh 'mkdir -p ansible-playbooks'
112
dir('ansible-playbooks'){
113
git([ url: "https://github.internet2.edu/docker/ansible-playbooks.git",
114
branch: "grouper-production", credentialsId: "jenkins-github-access-token" ])
115
}
116
117
stage 'Validate'
118
119
sh '/usr/local/bin/packer validate grouper-appliance.json'
120
121
stage 'Build Appliance - Grouper'
122
123
sh '/usr/local/bin/packer build grouper-appliance.json'
124
125
stage 'Sync appliances to S3 bucket'
126
127
sh 'aws s3 sync builds s3://internet2-appliance-us-west-1'
128
129
slackSend color: 'good', message: "BUILD SUCCESS: Comanage Appliance build success. ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL} |Open>)"
130
131
}
132
133
catch (err) {
134
currentBuild.result = "FAILURE"
135
136
slackSend color: 'danger', message: "BUILD ERROR: There was a problem with Comanage Appliance. ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL} |Open>) \n\n ${err}"
137
138
throw err
139
}
140
}
Mason Packard
Aug 19, 2016
141
}
142
143
def handleError(String message){
144
echo "${message}"
145
currentBuild.setResult("FAILED")
146
slackSend color: 'danger', message: "${message}"
147
//step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chris.bynum@levvel.io', sendToIndividuals: true])
148
sh 'exit 1'
149
}
You can’t perform that action at this time.