diff --git a/Jenkinsfile b/Jenkinsfile index adcf109..2def24c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,6 +3,7 @@ pipeline { environment { maintainer = "t" imagename = 'm' + imagename_data = 'md' tag = 'l' } stages { @@ -11,13 +12,14 @@ pipeline { script { maintainer = maintain() imagename = imagename() + imagename_data = imagename_data() if(env.BRANCH_NAME == "master") { tag = "latest" } else { tag = env.BRANCH_NAME } - if(!imagename){ - echo "You must define an imagename in common.bash" + if(!imagename || !imagename_data){ + echo "You must define imagename and imagename_data in common.bash" currentBuild.result = 'FAILURE' } sh 'mkdir -p bin' @@ -56,13 +58,21 @@ pipeline { // sh 'cd test-compose && docker-compose down' baseImg.push("$tag") } + docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { + def baseImg = docker.build("$maintainer/$imagename_data", "--no-cache midpoint/midpoint-data") + // test the environment + // sh 'cd test-compose && ./compose.sh' + // bring down after testing + // sh 'cd test-compose && docker-compose down' + baseImg.push("$tag") + } } } } stage('Notify') { steps { echo "$maintainer" - //slackSend color: 'good', message: "$maintainer/$imagename:$tag pushed to DockerHub" + slackSend color: 'good', message: "$maintainer/$imagename:$tag and $maintainer/$imagename_data:$tag pushed to DockerHub" } } } @@ -72,7 +82,7 @@ pipeline { } failure { // slackSend color: 'good', message: "Build failed" - handleError("BUILD ERROR: There was a problem building ${maintainer}/${imagename}:${tag}.") + handleError("BUILD ERROR: There was a problem building ${maintainer}/${imagename}:${tag} or ${maintainer}/${imagename_data}:${tag}.") } } } @@ -88,10 +98,15 @@ def imagename() { matcher ? matcher[0][1] : null } +def imagename_data() { + def matcher = readFile('common.bash') =~ 'imagename_data="(.+)"' + matcher ? matcher[0][1] : null +} + def handleError(String message){ echo "${message}" currentBuild.setResult("FAILED") - //slackSend color: 'danger', message: "${message}" + slackSend color: 'danger', message: "${message}" //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chubing@internet2.edu', sendToIndividuals: true]) sh 'exit 1' } diff --git a/common.bash b/common.bash index 45039e1..5f9b7b0 100644 --- a/common.bash +++ b/common.bash @@ -1,2 +1,3 @@ maintainer="tier" imagename="midpoint" +imagename_data="midpoint-mariadb"