From 540c5e4bac13d338f824b3edfb8c0ec430c8a83e Mon Sep 17 00:00:00 2001 From: GraceRuan Date: Thu, 2 Nov 2023 12:11:00 -0700 Subject: [PATCH 1/4] feat: separate inventory --- pipelines/shared/Jenkinsfile | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/pipelines/shared/Jenkinsfile b/pipelines/shared/Jenkinsfile index c30a8d2..6d32071 100644 --- a/pipelines/shared/Jenkinsfile +++ b/pipelines/shared/Jenkinsfile @@ -53,6 +53,28 @@ pipeline { ]) } } + stage('Checkout INFRA dev-all-in-one') { + agent { + label Podman.AGENT_LABEL_APP + } + steps { + checkout([ + $class: 'GitSCM', + branches: [[name: "refs/heads/release/1.0.0"]], + doGenerateSubmoduleConfigurations: false, + extensions: [ + [$class: 'RelativeTargetDirectory', relativeTargetDir: "infra-dev-all-in-one"] + ], + submoduleCfg: [], + userRemoteConfigs: [ + [ + credentialsId: 'ci-user', + url: "https://apps.nrs.gov.bc.ca/int/stash/scm/infra/dev-all-in-one.git" + ] + ] + ]) + } + } stage('Deploy to development') { agent { label Podman.AGENT_LABEL_APP @@ -112,9 +134,10 @@ pipeline { options: "-v \$(pwd)/dev-all-in-one:/ansible/dev-all-in-one \ -v \$(pwd)/app:/ansible/app \ -v \$(pwd)/dev-all-in-one/roles:/etc/ansible/roles \ + -v \$(pwd)/infra-dev-all-in-one:/ansible/infra-dev-all-in-one \ -v \$(pwd)/files/ansible/ansible.cfg:/etc/ansible/ansible.cfg \ -e PODMAN_*", - command: 'ansible-playbook -i dev-all-in-one/inventory/${PODMAN_ANSIBLE_INVENTORY_PATH} \ + command: 'ansible-playbook -i infra-dev-all-in-one/inventory/${PODMAN_ANSIBLE_INVENTORY_PATH} \ app/playbooks/playbook.yaml --extra-vars "env_vars=dev"') podman.logout(authfile: "${env.AUTHFILE}") intention.endAction("install") From e88268f7ed276ea7ff72bac354021f2caa02c0ae Mon Sep 17 00:00:00 2001 From: GraceRuan Date: Thu, 2 Nov 2023 13:44:11 -0700 Subject: [PATCH 2/4] fix: use parallel steps --- pipelines/shared/Jenkinsfile | 89 +++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/pipelines/shared/Jenkinsfile b/pipelines/shared/Jenkinsfile index 6d32071..96b707a 100644 --- a/pipelines/shared/Jenkinsfile +++ b/pipelines/shared/Jenkinsfile @@ -31,50 +31,55 @@ pipeline { } } } - stage('Checkout dev-all-in-one') { - agent { - label Podman.AGENT_LABEL_APP - } - steps { - checkout([ - $class: 'GitSCM', - branches: [[name: "refs/tags/v1.0.1"]], - doGenerateSubmoduleConfigurations: false, - extensions: [ - [$class: 'RelativeTargetDirectory', relativeTargetDir: "dev-all-in-one"] - ], - submoduleCfg: [], - userRemoteConfigs: [ - [ - credentialsId: 'ci-user', - url: "https://bwa.nrs.gov.bc.ca/int/stash/scm/oneteam/dev-all-in-one.git" - ] - ] - ]) - } - } - stage('Checkout INFRA dev-all-in-one') { - agent { - label Podman.AGENT_LABEL_APP - } - steps { - checkout([ - $class: 'GitSCM', - branches: [[name: "refs/heads/release/1.0.0"]], - doGenerateSubmoduleConfigurations: false, - extensions: [ - [$class: 'RelativeTargetDirectory', relativeTargetDir: "infra-dev-all-in-one"] - ], - submoduleCfg: [], - userRemoteConfigs: [ - [ - credentialsId: 'ci-user', - url: "https://apps.nrs.gov.bc.ca/int/stash/scm/infra/dev-all-in-one.git" - ] - ] - ]) + stage('Checkout Source'){ + parallel{ + stage('Checkout dev-all-in-one') { + agent { + label Podman.AGENT_LABEL_APP + } + steps { + checkout([ + $class: 'GitSCM', + branches: [[name: "refs/tags/v1.0.1"]], + doGenerateSubmoduleConfigurations: false, + extensions: [ + [$class: 'RelativeTargetDirectory', relativeTargetDir: "dev-all-in-one"] + ], + submoduleCfg: [], + userRemoteConfigs: [ + [ + credentialsId: 'ci-user', + url: "https://bwa.nrs.gov.bc.ca/int/stash/scm/oneteam/dev-all-in-one.git" + ] + ] + ]) + } + } + stage('Checkout INFRA dev-all-in-one') { + agent { + label Podman.AGENT_LABEL_APP + } + steps { + checkout([ + $class: 'GitSCM', + branches: [[name: "release/1.0.0"]], + doGenerateSubmoduleConfigurations: false, + extensions: [ + [$class: 'RelativeTargetDirectory', relativeTargetDir: "infra-dev-all-in-one"] + ], + submoduleCfg: [], + userRemoteConfigs: [ + [ + credentialsId: 'ci-user', + url: "https://apps.nrs.gov.bc.ca/int/stash/scm/infra/dev-all-in-one.git" + ] + ] + ]) + } + } } } + stage('Deploy to development') { agent { label Podman.AGENT_LABEL_APP From eb2ef18487e4993d78f4d6e841afddfc8f0bc29d Mon Sep 17 00:00:00 2001 From: GraceRuan Date: Thu, 2 Nov 2023 15:00:36 -0700 Subject: [PATCH 3/4] fix: change apps to bwa --- pipelines/shared/Jenkinsfile | 93 +++++++++++++++++------------------- 1 file changed, 44 insertions(+), 49 deletions(-) diff --git a/pipelines/shared/Jenkinsfile b/pipelines/shared/Jenkinsfile index 96b707a..d9ef0df 100644 --- a/pipelines/shared/Jenkinsfile +++ b/pipelines/shared/Jenkinsfile @@ -30,56 +30,51 @@ pipeline { } } } + } + stage('Checkout dev-all-in-one') { + agent { + label Podman.AGENT_LABEL_APP + } + steps { + checkout([ + $class: 'GitSCM', + branches: [[name: "refs/tags/v1.0.1"]], + doGenerateSubmoduleConfigurations: false, + extensions: [ + [$class: 'RelativeTargetDirectory', relativeTargetDir: "dev-all-in-one"] + ], + submoduleCfg: [], + userRemoteConfigs: [ + [ + credentialsId: 'ci-user', + url: "https://bwa.nrs.gov.bc.ca/int/stash/scm/oneteam/dev-all-in-one.git" + ] + ] + ]) + } } - stage('Checkout Source'){ - parallel{ - stage('Checkout dev-all-in-one') { - agent { - label Podman.AGENT_LABEL_APP - } - steps { - checkout([ - $class: 'GitSCM', - branches: [[name: "refs/tags/v1.0.1"]], - doGenerateSubmoduleConfigurations: false, - extensions: [ - [$class: 'RelativeTargetDirectory', relativeTargetDir: "dev-all-in-one"] - ], - submoduleCfg: [], - userRemoteConfigs: [ - [ - credentialsId: 'ci-user', - url: "https://bwa.nrs.gov.bc.ca/int/stash/scm/oneteam/dev-all-in-one.git" - ] - ] - ]) - } - } - stage('Checkout INFRA dev-all-in-one') { - agent { - label Podman.AGENT_LABEL_APP - } - steps { - checkout([ - $class: 'GitSCM', - branches: [[name: "release/1.0.0"]], - doGenerateSubmoduleConfigurations: false, - extensions: [ - [$class: 'RelativeTargetDirectory', relativeTargetDir: "infra-dev-all-in-one"] - ], - submoduleCfg: [], - userRemoteConfigs: [ - [ - credentialsId: 'ci-user', - url: "https://apps.nrs.gov.bc.ca/int/stash/scm/infra/dev-all-in-one.git" - ] - ] - ]) - } - } + stage('Checkout INFRA dev-all-in-one') { + agent { + label Podman.AGENT_LABEL_APP + } + steps { + checkout([ + $class: 'GitSCM', + branches: [[name: "release/1.0.0"]], + doGenerateSubmoduleConfigurations: false, + extensions: [ + [$class: 'RelativeTargetDirectory', relativeTargetDir: "inventory"] + ], + submoduleCfg: [], + userRemoteConfigs: [ + [ + credentialsId: 'ci-user', + url: "https://bwa.nrs.gov.bc.ca/int/stash/scm/infra/dev-all-in-one.git" + ] + ] + ]) } } - stage('Deploy to development') { agent { label Podman.AGENT_LABEL_APP @@ -139,10 +134,10 @@ pipeline { options: "-v \$(pwd)/dev-all-in-one:/ansible/dev-all-in-one \ -v \$(pwd)/app:/ansible/app \ -v \$(pwd)/dev-all-in-one/roles:/etc/ansible/roles \ - -v \$(pwd)/infra-dev-all-in-one:/ansible/infra-dev-all-in-one \ + -v \$(pwd)/inventory/inventory:/ansible/inventory \ -v \$(pwd)/files/ansible/ansible.cfg:/etc/ansible/ansible.cfg \ -e PODMAN_*", - command: 'ansible-playbook -i infra-dev-all-in-one/inventory/${PODMAN_ANSIBLE_INVENTORY_PATH} \ + command: 'ansible-playbook -i inventory/${PODMAN_ANSIBLE_INVENTORY_PATH} \ app/playbooks/playbook.yaml --extra-vars "env_vars=dev"') podman.logout(authfile: "${env.AUTHFILE}") intention.endAction("install") From 0619a6cc4d8598c25a1ed941b2c4d265bef934a5 Mon Sep 17 00:00:00 2001 From: GraceRuan Date: Thu, 2 Nov 2023 15:29:02 -0700 Subject: [PATCH 4/4] fix: change inventory folder to infra --- pipelines/shared/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipelines/shared/Jenkinsfile b/pipelines/shared/Jenkinsfile index d9ef0df..e93dcee 100644 --- a/pipelines/shared/Jenkinsfile +++ b/pipelines/shared/Jenkinsfile @@ -63,7 +63,7 @@ pipeline { branches: [[name: "release/1.0.0"]], doGenerateSubmoduleConfigurations: false, extensions: [ - [$class: 'RelativeTargetDirectory', relativeTargetDir: "inventory"] + [$class: 'RelativeTargetDirectory', relativeTargetDir: "infra"] ], submoduleCfg: [], userRemoteConfigs: [ @@ -134,7 +134,7 @@ pipeline { options: "-v \$(pwd)/dev-all-in-one:/ansible/dev-all-in-one \ -v \$(pwd)/app:/ansible/app \ -v \$(pwd)/dev-all-in-one/roles:/etc/ansible/roles \ - -v \$(pwd)/inventory/inventory:/ansible/inventory \ + -v \$(pwd)/infra/inventory:/ansible/inventory \ -v \$(pwd)/files/ansible/ansible.cfg:/etc/ansible/ansible.cfg \ -e PODMAN_*", command: 'ansible-playbook -i inventory/${PODMAN_ANSIBLE_INVENTORY_PATH} \