Skip to content

Commit

Permalink
Parallelize Docker pushes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffbyrnes committed Jul 21, 2016
1 parent cf309ae commit c62dcf0
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions Jenkinsfile
@@ -1,5 +1,6 @@
def name = 'registry.evertrue.com/evertrue/passenger'
def safeBranchName = env.BRANCH_NAME.replaceAll(/\//, "-")
def tag = "${safeBranchName}-${env.BUILD_ID}"

node {
try {
Expand All @@ -8,18 +9,23 @@ node {

stage 'Build Docker images'
parallel ruby22: {
buildImage('ruby22', safeBranchName)
buildImage('ruby22', tag)
}, ruby23: {
buildImage('ruby23', safeBranchName)
buildImage('ruby23', tag)
}, full: {
buildImage('full', safeBranchName)
buildImage('full', tag)
},
failFast: true

stage 'Push Docker images'
sh "docker push ${name}-ruby22:${safeBranchName}-${env.BUILD_ID}"
sh "docker push ${name}-ruby23:${safeBranchName}-${env.BUILD_ID}"
sh "docker push ${name}-full:${safeBranchName}-${env.BUILD_ID}"
parallel ruby22: {
pushImage("${name}-ruby22", tag)
}, ruby23: {
pushImage("${name}-ruby23", tag)
}, full: {
pushImage("${name}-full", tag)
},
failFast: true

slackSend color: 'good', message: "${env.JOB_NAME} - #${env.BUILD_NUMBER} Success (<${env.BUILD_URL}|Open>)"
} catch (e) {
Expand All @@ -31,6 +37,10 @@ node {
step([$class: 'GitHubCommitStatusSetter'])
}

def buildImage(image, safeBranchName) {
sh "docker build -t registry.evertrue.com/evertrue/passenger-${image}:${safeBranchName}-${env.BUILD_ID} -f Dockerfile-${image} ."
def buildImage(image, tag) {
sh "docker build -t registry.evertrue.com/evertrue/passenger-${image}:${tag} -f Dockerfile-${image} ."
}

def pushImage(image, tag) {
sh "docker push ${image}:${tag}"
}

0 comments on commit c62dcf0

Please sign in to comment.