From 735aa27c515434b9ef20af654a8bfc25b6ff6972 Mon Sep 17 00:00:00 2001 From: tonsV2 Date: Mon, 13 Nov 2023 17:56:01 +0700 Subject: [PATCH] ci:update image tag (#15607) (#15670) * ci: update image tag * ci: compute instance name before stripping hotfix segment * ci: make 'Update IM Play instance' stage the last stage in the pipeline * ci: move stage into stages --- jenkinsfiles/stable | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/jenkinsfiles/stable b/jenkinsfiles/stable index a16e8d9b26b9..d0b724f6993a 100644 --- a/jenkinsfiles/stable +++ b/jenkinsfiles/stable @@ -123,12 +123,25 @@ pipeline { } } + stage ('Sync WAR') { + steps { + echo 'Syncing WAR ...' + sh 'curl "https://raw.githubusercontent.com/dhis2/dhis2-server-setup/master/ci/scripts/copy-war-s3.sh" -O' + sh 'chmod +x copy-war-s3.sh' + sh './copy-war-s3.sh stable ${GIT_BRANCH}' + } + } + stage('Update IM Play instance') { + when { + expression { !env.DOCKER_IMAGE_TAG.endsWith("rc") } + } + environment { HTTP = "http --check-status" IM_REPO_URL = "https://github.com/dhis2-sre/im-manager" IM_HOST = "https://api.im.dhis2.org" - INSTANCE_URL = "https://play.im.dhis2.org/stable" + INSTANCE_URL = "https://play.im.dhis2.org" IMAGE_REPOSITORY = "core" IMAGE_PULL_POLICY = "Always" FLYWAY_MIGRATE_OUT_OF_ORDER = "true" @@ -140,9 +153,6 @@ pipeline { } steps { - when { - expression { !env.DOCKER_IMAGE_TAG.endsWith("rc") } - } echo 'Creating DHIS2 instance on IM...' script { withCredentials([usernamePassword(credentialsId: 'dhis2-im-bot', passwordVariable: 'PASSWORD', usernameVariable: 'USER_EMAIL')]) { @@ -153,6 +163,9 @@ pipeline { if (version.startsWith("patch/")) { version = version.split("/")[1] } + env.IMAGE_TAG = version + def instanceName = "stable-${version.replace(".", "-")}" + // If version contains more than 2 dots... It's a hotfix def isHotfix = version.length() - version.replace(".", "").length() > 2 if (isHotfix) { @@ -170,11 +183,10 @@ pipeline { sh '[ -n "$DATABASE_ID" ]' echo "Database: ${env.DATABASE_ID}" - def name = "-${version.replace(".", "-")}" dir('scripts/instances') { - sh "(./findByName.sh play stable${name} && ./restart.sh play stable${name}) || ./deploy-dhis2.sh play stable${name}" + sh "(./findByName.sh play ${instanceName} && ./restart.sh play ${instanceName}) || ./deploy-dhis2.sh play ${instanceName}" timeout(5) { - waitFor.statusOk("${env.INSTANCE_URL}${name}") + waitFor.statusOk("${env.INSTANCE_URL}/${instanceName}") } } } @@ -182,15 +194,6 @@ pipeline { } } } - - stage ('Sync WAR') { - steps { - echo 'Syncing WAR ...' - sh 'curl "https://raw.githubusercontent.com/dhis2/dhis2-server-setup/master/ci/scripts/copy-war-s3.sh" -O' - sh 'chmod +x copy-war-s3.sh' - sh './copy-war-s3.sh stable ${GIT_BRANCH}' - } - } } post {