Skip to content
Permalink
Newer
Older
100644 89 lines (63 sloc) 2.29 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 'mkdir -p ansible-playbooks'
48
dir('ansible-playbooks'){
49
git([ url: "https://github.internet2.edu/docker/ansible-playbooks.git",
Jim Van Fleet
Sep 6, 2016
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
Jim Van Fleet
Sep 6, 2016
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
Jim Van Fleet
Sep 6, 2016
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"
65
stage 'Publish results'
67
sh "bin/perms.sh > results.txt"
69
slackSend color: 'good', message: "BUILD SUCCESS: Appliance build success. ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL} |Open>)"
70
71
slackSend color: 'good', message: readFile('./results.txt')
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}")
Mason Packard
Aug 19, 2016
80
}
81
82
def handleError(String message){
83
echo "${message}"
84
currentBuild.setResult("FAILED")
85
slackSend color: 'danger', message: "${message}"
86
//step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chris.bynum@levvel.io', sendToIndividuals: true])
88
sh 'exit 1'
You can’t perform that action at this time.