From 940da4410e1c443b6deb1e46421d8f74c87d625e Mon Sep 17 00:00:00 2001 From: TonsV2 Date: Thu, 26 Oct 2023 22:02:04 +0700 Subject: [PATCH 1/3] im-play/dev (#15481) * chore: deploy all supported dev branches [skip ci] * chore: use database slug rather than retrieving id [skip ci] * chore: clean up [skip ci] * chore: fix indent [skip ci] * chore: set image tag based on the branch [skip ci] * chore: test with 2.40 * chore: dns_rfc1035 can't start with numeric char * chore: misc. clean up (cherry picked from commit 90f5d0fe2c69c21f86ae65c207157e599cd0762d) Signed-off-by: TonsV2 --- jenkinsfiles/dev | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/jenkinsfiles/dev b/jenkinsfiles/dev index 51946b18b3aa..f55de4768daf 100644 --- a/jenkinsfiles/dev +++ b/jenkinsfiles/dev @@ -189,6 +189,59 @@ pipeline { } } + stage('Update IM Play dev instance') { + 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/dev" + IMAGE_REPOSITORY = "core-dev" + IMAGE_PULL_POLICY = "Always" + FLYWAY_MIGRATE_OUT_OF_ORDER = "true" + FLYWAY_REPAIR_BEFORE_MIGRATION = "true" + INSTANCE_TTL = "315360000" + STARTUP_PROBE_FAILURE_THRESHOLD = "50" + LIVENESS_PROBE_TIMEOUT_SECONDS = "3" + READINESS_PROBE_TIMEOUT_SECONDS = "3" + } + steps { + script { + withCredentials([usernamePassword(credentialsId: 'dhis2-im-bot', passwordVariable: 'PASSWORD', usernameVariable: 'USER_EMAIL')]) { + dir('im-manager') { + gitHelper.sparseCheckout(IM_REPO_URL, "${gitHelper.getLatestTag(IM_REPO_URL)}", '/scripts') + + echo 'Creating DHIS2 instance on IM...' + def branch = "" + if (env.GIT_BRANCH == 'master') { + env.IMAGE_TAG = "latest" + env.DATABASE_ID = "test-dbs-sierra-leone-dev-sql-gz" + } else { + env.IMAGE_TAG = env.GIT_BRANCH + branch = "-${env.GIT_BRANCH.replaceAll(".", "-")}" + + dir('scripts/databases') { + env.DATABASE_ID = sh( + returnStdout: true, + script: "./list.sh | jq -r '.[] | select(.name == \"test-dbs\") | .databases[] | select(.name == \"sierra-leone/${env.GIT_BRANCH}.sql.gz\") | .slug'" + ).trim() + } + } + + sh '[ -n "$DATABASE_ID" ]' + echo "Database: ${env.DATABASE_ID}" + + dir('scripts/instances') { + sh "(./findByName.sh play dev${branch} && ./restart.sh play dev${branch}) || ./deploy-dhis2.sh play dev${branch}" + timeout(5) { + waitFor.statusOk("${env.INSTANCE_URL}") + } + } + } + } + } + } + } + post { always { archiveArtifacts artifacts: '**/target/surefire-reports/TEST-*.xml' From 7f1998d29fdfae1d06fb235caf8bce58511e36b0 Mon Sep 17 00:00:00 2001 From: TonsV2 Date: Fri, 27 Oct 2023 08:07:11 +0700 Subject: [PATCH 2/3] chore: s/replaceAll/replace/ Signed-off-by: TonsV2 --- jenkinsfiles/dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkinsfiles/dev b/jenkinsfiles/dev index f55de4768daf..6f3d20de731a 100644 --- a/jenkinsfiles/dev +++ b/jenkinsfiles/dev @@ -217,7 +217,7 @@ pipeline { env.DATABASE_ID = "test-dbs-sierra-leone-dev-sql-gz" } else { env.IMAGE_TAG = env.GIT_BRANCH - branch = "-${env.GIT_BRANCH.replaceAll(".", "-")}" + branch = "-${env.GIT_BRANCH.replace(".", "-")}" dir('scripts/databases') { env.DATABASE_ID = sh( From 955e6b996eee29eb9cb493d0ae87f810949b8cd7 Mon Sep 17 00:00:00 2001 From: TonsV2 Date: Fri, 27 Oct 2023 08:39:28 +0700 Subject: [PATCH 3/3] ci: fix scope Signed-off-by: TonsV2 --- jenkinsfiles/dev | 82 ++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/jenkinsfiles/dev b/jenkinsfiles/dev index 6f3d20de731a..15528e6a2e6d 100644 --- a/jenkinsfiles/dev +++ b/jenkinsfiles/dev @@ -187,53 +187,53 @@ pipeline { } } } - } - stage('Update IM Play dev instance') { - 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/dev" - IMAGE_REPOSITORY = "core-dev" - IMAGE_PULL_POLICY = "Always" - FLYWAY_MIGRATE_OUT_OF_ORDER = "true" - FLYWAY_REPAIR_BEFORE_MIGRATION = "true" - INSTANCE_TTL = "315360000" - STARTUP_PROBE_FAILURE_THRESHOLD = "50" - LIVENESS_PROBE_TIMEOUT_SECONDS = "3" - READINESS_PROBE_TIMEOUT_SECONDS = "3" - } - steps { - script { - withCredentials([usernamePassword(credentialsId: 'dhis2-im-bot', passwordVariable: 'PASSWORD', usernameVariable: 'USER_EMAIL')]) { - dir('im-manager') { - gitHelper.sparseCheckout(IM_REPO_URL, "${gitHelper.getLatestTag(IM_REPO_URL)}", '/scripts') + stage('Update IM Play dev instance') { + 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/dev" + IMAGE_REPOSITORY = "core-dev" + IMAGE_PULL_POLICY = "Always" + FLYWAY_MIGRATE_OUT_OF_ORDER = "true" + FLYWAY_REPAIR_BEFORE_MIGRATION = "true" + INSTANCE_TTL = "315360000" + STARTUP_PROBE_FAILURE_THRESHOLD = "50" + LIVENESS_PROBE_TIMEOUT_SECONDS = "3" + READINESS_PROBE_TIMEOUT_SECONDS = "3" + } + steps { + script { + withCredentials([usernamePassword(credentialsId: 'dhis2-im-bot', passwordVariable: 'PASSWORD', usernameVariable: 'USER_EMAIL')]) { + dir('im-manager') { + gitHelper.sparseCheckout(IM_REPO_URL, "${gitHelper.getLatestTag(IM_REPO_URL)}", '/scripts') - echo 'Creating DHIS2 instance on IM...' - def branch = "" - if (env.GIT_BRANCH == 'master') { - env.IMAGE_TAG = "latest" - env.DATABASE_ID = "test-dbs-sierra-leone-dev-sql-gz" - } else { - env.IMAGE_TAG = env.GIT_BRANCH - branch = "-${env.GIT_BRANCH.replace(".", "-")}" + echo 'Creating DHIS2 instance on IM...' + def branch = "" + if (env.GIT_BRANCH == 'master') { + env.IMAGE_TAG = "latest" + env.DATABASE_ID = "test-dbs-sierra-leone-dev-sql-gz" + } else { + env.IMAGE_TAG = env.GIT_BRANCH + branch = "-${env.GIT_BRANCH.replace(".", "-")}" - dir('scripts/databases') { - env.DATABASE_ID = sh( - returnStdout: true, - script: "./list.sh | jq -r '.[] | select(.name == \"test-dbs\") | .databases[] | select(.name == \"sierra-leone/${env.GIT_BRANCH}.sql.gz\") | .slug'" - ).trim() + dir('scripts/databases') { + env.DATABASE_ID = sh( + returnStdout: true, + script: "./list.sh | jq -r '.[] | select(.name == \"test-dbs\") | .databases[] | select(.name == \"sierra-leone/${env.GIT_BRANCH}.sql.gz\") | .slug'" + ).trim() + } } - } - sh '[ -n "$DATABASE_ID" ]' - echo "Database: ${env.DATABASE_ID}" + sh '[ -n "$DATABASE_ID" ]' + echo "Database: ${env.DATABASE_ID}" - dir('scripts/instances') { - sh "(./findByName.sh play dev${branch} && ./restart.sh play dev${branch}) || ./deploy-dhis2.sh play dev${branch}" - timeout(5) { - waitFor.statusOk("${env.INSTANCE_URL}") + dir('scripts/instances') { + sh "(./findByName.sh play dev${branch} && ./restart.sh play dev${branch}) || ./deploy-dhis2.sh play dev${branch}" + timeout(5) { + waitFor.statusOk("${env.INSTANCE_URL}") + } } } }