Skip to content

Commit

Permalink
implement SKIP_IMAGE_PUBLISH
Browse files Browse the repository at this point in the history
  • Loading branch information
Schnitzel committed Feb 7, 2020
1 parent 9aa9076 commit cbe2073
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Jenkinsfile
Expand Up @@ -5,7 +5,10 @@ node {
env.MINISHIFT_HOME = "/data/jenkins/.minishift"

withEnv(['AWS_BUCKET=jobs.amazeeio.services', 'AWS_DEFAULT_REGION=us-east-2']) {
withCredentials([usernamePassword(credentialsId: 'aws-s3-lagoon', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_ACCESS_KEY')]) {
withCredentials([
usernamePassword(credentialsId: 'aws-s3-lagoon', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_ACCESS_KEY'),
string(credentialsId: 'SKIP_IMAGE_PUBLISH', variable: 'SKIP_IMAGE_PUBLISH')
]) {
try {
env.CI_BUILD_TAG = env.BUILD_TAG.replaceAll('%2f','').replaceAll("[^A-Za-z0-9]+", "").toLowerCase()
env.SAFEBRANCH_NAME = env.BRANCH_NAME.replaceAll('%2f','-').replaceAll("[^A-Za-z0-9]+", "-").toLowerCase()
Expand All @@ -19,7 +22,6 @@ node {
stage ('Checkout') {
def checkout = checkout scm
env.GIT_COMMIT = checkout["GIT_COMMIT"]
sh "git fetch --tags"
}

stage ('build images') {
Expand Down Expand Up @@ -51,8 +53,12 @@ node {
'push images to amazeeiolagoon': {
stage ('push images to amazeeiolagoon/*') {
withCredentials([string(credentialsId: 'amazeeiojenkins-dockerhub-password', variable: 'PASSWORD')]) {
sh 'docker login -u amazeeiojenkins -p $PASSWORD'
sh "make publish-amazeeiolagoon-baseimages publish-amazeeiolagoon-serviceimages BRANCH_NAME=${SAFEBRANCH_NAME} -j4"
if (env.SKIP_IMAGE_PUBLISH != 'true') {
sh 'docker login -u amazeeiojenkins -p $PASSWORD'
sh "make publish-amazeeiolagoon-baseimages publish-amazeeiolagoon-serviceimages BRANCH_NAME=${SAFEBRANCH_NAME} -j4"
} else {
sh 'echo "skipped because of SKIP_IMAGE_PUBLISH env variable"'
}
}
}
}
Expand Down Expand Up @@ -86,7 +92,7 @@ node {
)
}

if (env.TAG_NAME) {
if (env.TAG_NAME && env.SKIP_IMAGE_PUBLISH != 'true') {
stage ('publish-amazeeio') {
withCredentials([string(credentialsId: 'amazeeiojenkins-dockerhub-password', variable: 'PASSWORD')]) {
sh 'docker login -u amazeeiojenkins -p $PASSWORD'
Expand All @@ -95,7 +101,7 @@ node {
}
}

if (env.BRANCH_NAME == 'master') {
if (env.BRANCH_NAME == 'master' && env.SKIP_IMAGE_PUBLISH != 'true') {
stage ('save-images-s3') {
sh "make s3-save -j8"
}
Expand Down

0 comments on commit cbe2073

Please sign in to comment.