-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jim Van Fleet
committed
Sep 6, 2016
1 parent
0053180
commit c33dc1b
Showing
1 changed file
with
69 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,130 +1,88 @@ | ||
| #!groovy | ||
| // pipeline file for building appliances | ||
|
|
||
| echo "My Branch is: ${env.BRANCH_NAME}" | ||
|
|
||
| BRANCH_TEST = "${env.BRANCH_NAME}" | ||
|
|
||
| if (BRANCH_TEST=="shibboleth-production"){ | ||
| node('packer') { | ||
| currentBuild.result = "SUCCESS" | ||
|
|
||
| try { | ||
| stage 'Cleanup & Setup' | ||
| sh 'rm -rf output-shibboleth-*' | ||
| sh 'rm -rf "/Users/levvel/VirtualBox VMs/shibboleth-appliance-*"' | ||
| sh 'rm -rf builds' | ||
| sh 'mkdir -p builds' | ||
|
|
||
| withCredentials([[$class: 'FileBinding', credentialsId: 'tier-aws-config', variable: 'FILE']]) { | ||
| ws { | ||
| sh 'mkdir -p ~/.aws' | ||
| sh 'cp $FILE ~/.aws/config' | ||
| } | ||
| } | ||
|
|
||
| withCredentials([[$class: 'FileBinding', credentialsId: 'tier-aws-credentials', variable: 'FILE']]) { | ||
| ws { | ||
| sh 'mkdir -p ~/.aws' | ||
| sh 'cp $FILE ~/.aws/credentials' | ||
| } | ||
| } | ||
|
|
||
| stage 'Checkout' | ||
|
|
||
| checkout scm | ||
|
|
||
| stage 'Acquire ansible-playbooks' | ||
|
|
||
| sh 'mkdir -p ansible-playbooks' | ||
| dir('ansible-playbooks'){ | ||
| git([ url: "https://github.internet2.edu/docker/ansible-playbooks.git", | ||
| branch: "shibboleth-production", credentialsId: "jenkins-github-access-token" ]) | ||
| } | ||
|
|
||
| stage 'Validate' | ||
|
|
||
| sh '/usr/local/bin/packer validate shibboleth-appliance.json' | ||
|
|
||
| stage 'Build Appliance - Shibboleth' | ||
|
|
||
| sh '/usr/local/bin/packer build shibboleth-appliance.json' | ||
|
|
||
| stage 'Sync appliances to S3 bucket' | ||
|
|
||
| sh 'aws s3 sync builds s3://internet2-tier-appliance-us-west-1' | ||
|
|
||
| slackSend color: 'good', message: "BUILD SUCCESS: Shibboleth Appliance build success. ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL} |Open>)" | ||
| node('packer') { | ||
| currentBuild.result = "SUCCESS" | ||
|
|
||
| stage 'Appliance build' | ||
| echo "My Branch is: ${env.BRANCH_NAME}" | ||
|
|
||
| BRANCH_TEST = "${env.BRANCH_NAME}" | ||
|
|
||
| if (BRANCH_TEST=="shibboleth-production"){ | ||
| performBuild("shibboleth") | ||
| } else if (BRANCH_TEST=="grouper-production"){ | ||
| performBuild("grouper") | ||
| } else if (BRANCH_TEST=="comanage-production"){ | ||
| performBuild("comanage") | ||
| } | ||
|
|
||
| } | ||
|
|
||
| def performBuild(String project){ | ||
| try { | ||
| stage 'Cleanup & Setup' | ||
| sh "rm -rf output-${project}-*" | ||
| sh "rm -rf \"/Users/levvel/VirtualBox VMs/${project}-appliance-*\"" | ||
| sh 'rm -rf builds' | ||
| sh 'mkdir -p builds' | ||
|
|
||
| withCredentials([[$class: 'FileBinding', credentialsId: 'tier-aws-config', variable: 'FILE']]) { | ||
| ws { | ||
| sh 'mkdir -p ~/.aws' | ||
| sh 'cp $FILE ~/.aws/config' | ||
| } | ||
| } | ||
|
|
||
| catch (err) { | ||
| currentBuild.result = "FAILURE" | ||
|
|
||
| slackSend color: 'danger', message: "BUILD ERROR: There was a problem with Shibboleth Appliance. ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL} |Open>) \n\n ${err}" | ||
|
|
||
| throw err | ||
| withCredentials([[$class: 'FileBinding', credentialsId: 'tier-aws-credentials', variable: 'FILE']]) { | ||
| ws { | ||
| sh 'mkdir -p ~/.aws' | ||
| sh 'cp $FILE ~/.aws/credentials' | ||
| } | ||
| } | ||
| } | ||
| } else if (BRANCH_TEST=="comanage-production"){ | ||
| node('packer') { | ||
| currentBuild.result = "SUCCESS" | ||
|
|
||
| try { | ||
| stage 'Cleanup & Setup ' | ||
| sh 'rm -rf output-comanage-*' | ||
| sh 'rm -rf "/Users/levvel/VirtualBox VMs/comange-appliance-*"' | ||
| sh 'rm -rf builds' | ||
| sh 'mkdir -p builds' | ||
|
|
||
| withCredentials([[$class: 'FileBinding', credentialsId: 'tier-aws-config', variable: 'FILE']]) { | ||
| ws { | ||
| sh 'mkdir -p ~/.aws' | ||
| sh 'cp $FILE ~/.aws/config' | ||
| } | ||
| } | ||
|
|
||
| withCredentials([[$class: 'FileBinding', credentialsId: 'tier-aws-credentials', variable: 'FILE']]) { | ||
| ws { | ||
| sh 'mkdir -p ~/.aws' | ||
| sh 'cp $FILE ~/.aws/credentials' | ||
| } | ||
| } | ||
|
|
||
| stage 'Checkout' | ||
| stage 'Checkout' | ||
|
|
||
| checkout scm | ||
| checkout scm | ||
|
|
||
| stage 'Acquire ansible-playbooks' | ||
| stage 'Acquire ansible-playbooks' | ||
|
|
||
| sh 'mkdir -p ansible-playbooks' | ||
| dir('ansible-playbooks'){ | ||
| git([ url: "https://github.internet2.edu/docker/ansible-playbooks.git", | ||
| branch: "comanage-production", credentialsId: "jenkins-github-access-token" ]) | ||
| } | ||
|
|
||
| stage 'Validate' | ||
|
|
||
| sh '/usr/local/bin/packer validate comange-appliance.json' | ||
| sh 'mkdir -p ansible-playbooks' | ||
| dir('ansible-playbooks'){ | ||
| git([ url: "https://github.internet2.edu/docker/ansible-playbooks.git", | ||
| branch: "{{project}}-production", credentialsId: "jenkins-github-access-token" ]) | ||
| } | ||
|
|
||
| stage 'Build Appliance - Comanage' | ||
| stage 'Validate' | ||
|
|
||
| sh '/usr/local/bin/packer build comanage-appliance.json' | ||
| sh "/usr/local/bin/packer validate {{project}}-appliance.json" | ||
|
|
||
| stage 'Sync appliances to S3 bucket' | ||
| stage 'Build Appliance' | ||
|
|
||
| sh 'aws s3 sync builds s3://internet2-tier-appliance-us-west-1' | ||
| sh "/usr/local/bin/packer build {{project}}-appliance.json" | ||
|
|
||
| slackSend color: 'good', message: "BUILD SUCCESS: Comanage Appliance build success. ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL} |Open>)" | ||
| stage 'Sync appliances to S3 bucket' | ||
|
|
||
| } | ||
| sh "aws s3 sync builds s3://internet2-tier-appliance-us-west-1" | ||
|
|
||
| stage 'Publish results' | ||
|
|
||
| sh "bin/perms.sh > results.txt" | ||
|
|
||
| catch (err) { | ||
| currentBuild.result = "FAILURE" | ||
| slackSend color: 'good', message: "BUILD SUCCESS: Shibboleth Appliance build success. ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL} |Open>)" | ||
|
|
||
| slackSend color: 'good', message: readFile('./results.txt') | ||
|
|
||
| sh "rm results.txt" | ||
|
|
||
| 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}" | ||
| } | ||
|
|
||
| throw err | ||
| } | ||
| catch (err) { | ||
| handleError("BUILD ERROR: There was a problem with ${project} Appliance. ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL} |Open>) \n\n ${err}") | ||
| } | ||
| } | ||
|
|
||
| def handleError(String message){ | ||
| echo "${message}" | ||
| currentBuild.setResult("FAILED") | ||
| slackSend color: 'danger', message: "${message}" | ||
| //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chris.bynum@levvel.io', sendToIndividuals: true]) | ||
| sh 'exit 1' | ||
| } |