From a403aa6a494f67c89b34e9f7986fa4f397d93019 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Wed, 27 Jul 2016 12:07:10 -0400 Subject: [PATCH 1/5] Using test script --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f2cf5c7..a4206fa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,7 +24,7 @@ node { stage 'Tests' - sh '/usr/local/bin/bats tests' + sh 'bin/test.sh' } \ No newline at end of file From bb0932cb47594ec18c62bf1a1bed84607611f5df Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Wed, 27 Jul 2016 12:29:36 -0400 Subject: [PATCH 2/5] Adding helper functions to support push --- Jenkinsfile | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a4206fa..d7171f8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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 @@ -17,8 +13,19 @@ 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' @@ -26,5 +33,22 @@ node { 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 } \ No newline at end of file From e34fb129ccc8954ca001c9a3ece21981995888b8 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Wed, 27 Jul 2016 12:32:53 -0400 Subject: [PATCH 3/5] Fixing helper typo --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d7171f8..826eaeb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -49,6 +49,6 @@ def maintainer() { } def imagename() { - def matcher = readFile('common.bash') =~ 'imagename=(.+)' + def matcher = readFile('common.bash') =~ 'imagename="(.+)"' matcher ? matcher[0][1] : null } \ No newline at end of file From 92fbe0466593f47b1c0506426824101c5be56f27 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Wed, 27 Jul 2016 12:36:26 -0400 Subject: [PATCH 4/5] Adding interpolation to tag --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 826eaeb..f93cf9b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,7 +37,7 @@ node { docker.withRegistry('https://registry.hub.docker.com/', 'dockerhub-bigfleet') { def baseImg = docker.build("$maintainer/$imagename") - baseImg.push('$tag') + baseImg.push("$tag") } From 21ba0f62c1765cd6739fa9ad187bf27118330038 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Wed, 27 Jul 2016 12:37:35 -0400 Subject: [PATCH 5/5] Correcting build stage label --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f93cf9b..4e56680 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ node { sh 'mv bin/* .' } - stage 'Debug' + stage 'Build' def maintainer = maintainer() def imagename = imagename()