Skip to content

Commit

Permalink
Adding helper functions to support push
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Van Fleet committed Jul 27, 2016
1 parent a403aa6 commit bb0932c
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
node {

env.DOCKERHUB_ACCOUNT = "bigfleet"
env.VERSION_TAG = "3.2.1" // latest version of the release
env.BUILD_TAG = "testing" // default tag to push for to the registry

stage 'Checkout'

checkout scm
Expand All @@ -17,14 +13,42 @@ node {
sh 'ls'
sh 'mv bin/* .'
}

stage 'Base'

stage 'Debug'

def maintainer = maintainer()
def imagename = imagename()
def tag = env.BRANCH_NAME
if(!imagename){
echo "You must define an imagename in common.bash"
currentBuild.result = 'FAILURE'
}
if(maintainer){
echo "Building ${maintainer}:${tag} for ${maintainer}"
}

sh 'bin/build.sh'

stage 'Tests'

sh 'bin/test.sh'

stage 'Push'

docker.withRegistry('https://registry.hub.docker.com/', 'dockerhub-bigfleet') {
def baseImg = docker.build("$maintainer/$imagename")
baseImg.push('$tag')
}


}

def maintainer() {
def matcher = readFile('common.bash') =~ 'maintainer="(.+)"'
matcher ? matcher[0][1] : 'tier'
}

def imagename() {
def matcher = readFile('common.bash') =~ 'imagename=(.+)'
matcher ? matcher[0][1] : null
}

0 comments on commit bb0932c

Please sign in to comment.