Skip to content

Commit

Permalink
ci: move stage into stages
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsV2 committed Nov 6, 2023
1 parent ccc748f commit 7ce8374
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions jenkinsfiles/stable
Original file line number Diff line number Diff line change
Expand Up @@ -131,63 +131,63 @@ pipeline {
sh './copy-war-s3.sh stable ${GIT_BRANCH}'
}
}
}

stage('Update IM Play instance') {
when {
expression { !env.DOCKER_IMAGE_TAG.endsWith("rc") }
}
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"
IMAGE_REPOSITORY = "core"
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"
}
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"
IMAGE_REPOSITORY = "core"
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 {
echo 'Creating DHIS2 instance on IM...'
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')
steps {
echo 'Creating DHIS2 instance on IM...'
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')

def version = env.GIT_BRANCH
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) {
def endIndex = version.lastIndexOf(".")
version = version.substring(0, endIndex)
}
def version = env.GIT_BRANCH
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) {
def endIndex = version.lastIndexOf(".")
version = version.substring(0, endIndex)
}

dir('scripts/databases') {
env.DATABASE_ID = sh(
returnStdout: true,
script: "./list.sh | jq -r '.[] | select(.name == \"test-dbs\") | .databases[] | select(.name == \"sierra-leone/${version}.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/${version}.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 ${instanceName} && ./restart.sh play ${instanceName}) || ./deploy-dhis2.sh play ${instanceName}"
timeout(5) {
waitFor.statusOk("${env.INSTANCE_URL}/${instanceName}")
dir('scripts/instances') {
sh "(./findByName.sh play ${instanceName} && ./restart.sh play ${instanceName}) || ./deploy-dhis2.sh play ${instanceName}"
timeout(5) {
waitFor.statusOk("${env.INSTANCE_URL}/${instanceName}")
}
}
}
}
Expand Down

0 comments on commit 7ce8374

Please sign in to comment.