diff --git a/Jenkinsfile b/Jenkinsfile index 815eec4..d71d02e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,7 +24,7 @@ def performBuild(String project){ try { stage 'Cleanup & Setup' sh "rm -rf output-${project}-*" - sh "rm -rf \"~/VirtualBox VMs/${project}-appliance-*\"" + sh "bin/remove-${project}.sh" sh 'rm -rf builds' sh 'mkdir -p builds' @@ -75,14 +75,19 @@ def performBuild(String project){ } 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}") + 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") } } -def handleError(String message){ +def handleError(String message, String appliance_name){ echo "${message}" currentBuild.setResult("FAILED") slackSend color: 'danger', message: "${message}" //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chris.bynum@levvel.io', sendToIndividuals: true]) + + sh "VBoxManage controlvm ${appliance_name} poweroff" + + sh "VboxManage unregistervm ${appliance_name} --delete" + sh 'exit 1' } diff --git a/bin/remove-comanage.sh b/bin/remove-comanage.sh new file mode 100755 index 0000000..e56368b --- /dev/null +++ b/bin/remove-comanage.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +rm -rf $HOME/VirtualBox\ VMs/comanage-appliance-centos7-xfs/ diff --git a/bin/remove-grouper.sh b/bin/remove-grouper.sh new file mode 100755 index 0000000..4bbf6da --- /dev/null +++ b/bin/remove-grouper.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +rm -rf $HOME/VirtualBox\ VMs/grouper-appliance-centos7-xfs/ diff --git a/bin/remove-shibboleth.sh b/bin/remove-shibboleth.sh new file mode 100755 index 0000000..a106560 --- /dev/null +++ b/bin/remove-shibboleth.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +rm -rf $HOME/VirtualBox\ VMs/shibboleth-appliance-centos7-xfs/