From d1d5f8254856514734c183eb6311bca85451486a Mon Sep 17 00:00:00 2001 From: tonsV2 Date: Fri, 27 Oct 2023 00:08:20 +0800 Subject: [PATCH] ci: im-play/dev [2.40] (#15502) * 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 * ci: strip dash if master (#15498) Signed-off-by: TonsV2 (cherry picked from commit 3a36b68c2166a5ebfd44ab0c0eee1112de280d34) --- jenkinsfiles/dev | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/jenkinsfiles/dev b/jenkinsfiles/dev index 466ef4c7e2bd..3b6477519fc8 100644 --- a/jenkinsfiles/dev +++ b/jenkinsfiles/dev @@ -191,42 +191,48 @@ pipeline { stage('Update IM Play dev instance') { environment { HTTP = "http --check-status" - IM_HOST = "https://api.im.prod.test.c.dhis2.org" - INSTANCE_URL = "https://play.im.prod.test.c.dhis2.org/dev" + 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_TAG = "latest" 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 { - if (env.GIT_BRANCH == 'master') { - withCredentials([usernamePassword(credentialsId: 'dhis2-im-bot', passwordVariable: 'PASSWORD', usernameVariable: 'USER_EMAIL')]) { - dir('im-db-manager') { - gitHelper.sparseCheckout('https://github.com/dhis2-sre/im-database-manager', 'master', '/scripts') + 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') - dir('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 == \"whoami\") | .Databases[] | select(.Name == \"Sierra Leone - dev.sql.gz\") | .ID'" + 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_ID is ${env.DATABASE_ID}" } } - dir('im-manager') { - gitHelper.sparseCheckout('https://github.com/dhis2-sre/im-manager', 'master', '/scripts') + sh '[ -n "$DATABASE_ID" ]' + echo "Database: ${env.DATABASE_ID}" - dir('scripts') { - echo 'Creating DHIS2 instance on IM...' - sh "(./findByName.sh play dev && ./restart.sh play dev) || ./deploy-dhis2.sh play dev" - 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}") } } }