diff --git a/fe/fe-acp/cd-acp-frontend.Jenkinsfile b/fe/fe-acp/cd-acp-frontend.Jenkinsfile index 01ab8a4..bbecda4 100644 --- a/fe/fe-acp/cd-acp-frontend.Jenkinsfile +++ b/fe/fe-acp/cd-acp-frontend.Jenkinsfile @@ -1,33 +1,44 @@ pipeline { agent any parameters { - choice(name: 'ENV', choices: ['uat', 'beta'], description: 'Choose Environment') + choice(name: 'ENV', choices: ['uat', 'production'], description: 'Choose Environment') string(name: 'CI_JOB_BUILD_NUMBER', defaultValue: '', description: 'Build number of CI Job') } environment { PROJECT_NAME = 'acp' CI_JOB_NAME_UAT = 'CI-UAT-FE-ACP' // tên của job build code môi trường uat - CI_JOB_NAME_PROD = 'CI-PROD-FE-ACP' // tên của job build code môi trường prod - CI_JOB_NAME_BETA = 'CI-BETA-FE-ACP' // tên của job build code môi trường beta + CI_JOB_NAME_PRODUCTION = 'CI-PRODUCTION-FE-ACP' // tên của job build code môi trường beta CI_JOB_METADATA_FILENAME = "${params.ENV}_${PROJECT_NAME}_metadata.json" // tên file metadata đã được lưu từ job build code GIT_PAT_CREDENTIALS_ID = 'b03f36c4-bba3-4764-94ca-b620651b2a68' // Id của Personal Access Token lưu trên jenkins GIT_ANSIBLE_URL = 'work.gct.com.vn/thienvv/nsg_ansible.git' - GIT_ANSIBLE_BRANCH = 'v2' + GIT_ANSIBLE_BRANCH = 'v3' NEXUS_CREDENTIALS = credentials('Nexus_credential') ANSIBLE_SSH_CONNECTION = 'root@103.166.183.172 -p 24700' - ANSIBLE_FOLDER_PATH = '/srv/ansible_v2' - ANSIBLE_INVENTORY_PATH = "inventory/${params.ENV}.ini" - ANSIBLE_PLAYBOOK_PATH = 'playbooks/deploy_fe.yml' + ANSIBLE_FOLDER_PATH = '/srv/ansible_v3' + ANSIBLE_PLAYBOOK_PATH = 'playbooks/frontend/deploy_acp_frontend.yml' TELEGRAM_CHAT_ID = -4678013464 TELEGRAM_BOT_TOKEN = credentials('TELEGRAM_BOT_TOKEN') } stages { + stage('Set up') { + steps { + script { + if (params.ENV == 'uat') { + env.ANSIBLE_INVENTORY_PATH = 'inventory/uat/hosts.ini' + } else if (params.ENV == 'production') { + env.ANSIBLE_INVENTORY_PATH = 'inventory/production/hosts.ini' + } + echo "ANSIBLE_INVENTORY_PATH is set to: ${env.ANSIBLE_INVENTORY_PATH}" + } + } + } + stage('Retrieve Artifact Metadata From CI Job') { steps { script { @@ -35,8 +46,8 @@ pipeline { case 'uat': env.CI_JOB_NAME = env.CI_JOB_NAME_UAT break - case 'beta': - env.CI_JOB_NAME = env.CI_JOB_NAME_BETA + case 'production': + env.CI_JOB_NAME = env.CI_JOB_NAME_PRODUCTION break default: error "Unsupported environment: ${params.ENV}" @@ -80,8 +91,6 @@ pipeline { env.ANSIBLE_FOLDER_PATH, env.ANSIBLE_INVENTORY_PATH, env.ANSIBLE_PLAYBOOK_PATH, - params.ENV, - env.PROJECT_NAME, env.NEXUS_URL, env.NEXUS_ARTIFACT_NAME, env.NEXUS_CREDENTIALS_USR, @@ -205,8 +214,6 @@ def triggerAnsible( String ansibleansibleFolderPath, String inventoryPath, String playbookPath, - String deployENV, - String projectName, String nexusUrl, String nexusArtifactName, String nexusUsername, @@ -218,9 +225,7 @@ def triggerAnsible( ssh ${sshAnsibleConnection} " cd ${ansibleansibleFolderPath} && ansible-playbook -i ${inventoryPath} ${playbookPath} \\ - -e 'deploy_env=${deployENV} \\ - project_name=${projectName} \\ - nexus_url=${nexusUrl} \\ + -e 'nexus_url=${nexusUrl} \\ artifact_name=${nexusArtifactName} \\ nexus_username=${nexusUsername} \\ nexus_password=${nexusPassword}' -vvvv diff --git a/fe/fe-acp/ci-beta-acp-frontend.Jenkinsfile b/fe/fe-acp/ci-production-acp-frontend.Jenkinsfile similarity index 99% rename from fe/fe-acp/ci-beta-acp-frontend.Jenkinsfile rename to fe/fe-acp/ci-production-acp-frontend.Jenkinsfile index 4bdabe1..dd452a4 100644 --- a/fe/fe-acp/ci-beta-acp-frontend.Jenkinsfile +++ b/fe/fe-acp/ci-production-acp-frontend.Jenkinsfile @@ -7,7 +7,7 @@ pipeline { GIT_BRANCH = 'main' PROJECT_NAME = 'acp' - ENV = 'beta' + ENV = 'production' TRIGGER_JOB_NAME = 'CD_FE_ACP' METADATA_FILENAME = "${env.ENV}_${PROJECT_NAME}_metadata.json" diff --git a/fe/fe-portal/cd-portal-frontend.Jenkinsfile b/fe/fe-portal/cd-portal-frontend.Jenkinsfile index e07d5d4..253308f 100644 --- a/fe/fe-portal/cd-portal-frontend.Jenkinsfile +++ b/fe/fe-portal/cd-portal-frontend.Jenkinsfile @@ -1,33 +1,52 @@ pipeline { agent any parameters { - choice(name: 'ENV', choices: ['uat', 'beta'], description: 'Choose Environment') + choice(name: 'ENV', choices: ['uat', 'production'], description: 'Choose Environment') choice(name: 'PORTAL_NAME', choices: ['ktdt', 'hnt'], description: 'Choose SITE NAME') string(name: 'CI_JOB_BUILD_NUMBER', defaultValue: '', description: 'Build number of CI Job') } environment { PROJECT_NAME = 'portal' CI_JOB_NAME_UAT = 'CI-UAT-FE-PORTAL' // tên của job build code môi trường uat - CI_JOB_NAME_BETA = 'CI-BETA-FE-PORTAL' // tên của job build code môi trường prod + CI_JOB_NAME_PRODUCTION = 'CI-PRODUCTION-FE-PORTAL' // tên của job build code môi trường prod CI_JOB_METADATA_FILENAME = "${env.ENV}_${env.PROJECT_NAME}_${params.PORTAL_NAME}_metadata.json" // tên file metadata đã được lưu từ job build code - GIT_PAT_CREDENTIALS_ID = 'b03f36c4-bba3-4764-94ca-b620651b2a68' // Id của Personal Access Token lưu trên jenkins - GIT_ANSIBLE_URL = 'work.gct.com.vn/thienvv/nsg_ansible.git' - GIT_ANSIBLE_BRANCH = 'v2' - NEXUS_CREDENTIALS = credentials('Nexus_credential') ANSIBLE_SSH_CONNECTION = 'root@103.166.183.172 -p 24700' - ANSIBLE_FOLDER_PATH = '/srv/ansible_v2' - ANSIBLE_INVENTORY_PATH = "inventory/${params.ENV}.ini" - ANSIBLE_PLAYBOOK_PATH = 'playbooks/deploy_fe_portal.yml' + GIT_PAT_CREDENTIALS_ID = 'b03f36c4-bba3-4764-94ca-b620651b2a68' // Id của Personal Access Token lưu trên jenkins + GIT_ANSIBLE_URL = 'work.gct.com.vn/thienvv/nsg_ansible.git' + GIT_ANSIBLE_BRANCH = 'v3' + + ANSIBLE_FOLDER_PATH = '/srv/ansible_v3' TELEGRAM_CHAT_ID = -4678013464 TELEGRAM_BOT_TOKEN = credentials('TELEGRAM_BOT_TOKEN') } stages { + stage('Set up') { + steps { + script { + if (params.ENV == 'uat') { + env.ANSIBLE_INVENTORY_PATH = 'inventory/uat/hosts.ini' + } else if (params.ENV == 'production') { + env.ANSIBLE_INVENTORY_PATH = 'inventory/production/hosts.ini' + } + echo "ANSIBLE_INVENTORY_PATH is set to: ${env.ANSIBLE_INVENTORY_PATH}" + + if (params.PORTAL_NAME == 'ktdt') { + env.ANSIBLE_PLAYBOOK_PATH = 'playbooks/frontend/deploy_ktdt_portal_frontend.yml' + } else if (params.PORTAL_NAME == 'hnt') { + env.ANSIBLE_PLAYBOOK_PATH = 'playbooks/frontend/deploy_hnt_portal_frontend.yml' + } + + echo "ANSIBLE_PLAYBOOK_PATH is set to: ${env.ANSIBLE_PLAYBOOK_PATH}" + } + } + } + stage('Retrieve Artifact Metadata From CI Job') { steps { script { @@ -36,7 +55,7 @@ pipeline { env.CI_JOB_NAME = env.CI_JOB_NAME_UAT break case 'beta': - env.CI_JOB_NAME = env.CI_JOB_NAME_BETA + env.CI_JOB_NAME = env.CI_JOB_NAME_PRODUCTION break default: error "Unsupported environment: ${params.ENV}" @@ -80,9 +99,6 @@ pipeline { env.ANSIBLE_FOLDER_PATH, env.ANSIBLE_INVENTORY_PATH, env.ANSIBLE_PLAYBOOK_PATH, - params.ENV, - env.PROJECT_NAME, - env.PORTAL_NAME, env.NEXUS_URL, env.NEXUS_ARTIFACT_NAME, env.NEXUS_CREDENTIALS_USR, @@ -206,9 +222,6 @@ def triggerAnsible( String ansibleansibleFolderPath, String inventoryPath, String playbookPath, - String deployENV, - String projectName, - String portalName, String nexusUrl, String nexusArtifactName, String nexusUsername, @@ -220,10 +233,7 @@ def triggerAnsible( ssh ${sshAnsibleConnection} " cd ${ansibleansibleFolderPath} && ansible-playbook -i ${inventoryPath} ${playbookPath} \\ - -e 'deploy_env=${deployENV} \\ - project_name=${projectName} \\ - portal_name=${portalName} \\ - nexus_url=${nexusUrl} \\ + -e 'nexus_url=${nexusUrl} \\ artifact_name=${nexusArtifactName} \\ nexus_username=${nexusUsername} \\ nexus_password=${nexusPassword}' -vvvv diff --git a/fe/fe-portal/ci-beta-portal-frontend.Jenkinsfile b/fe/fe-portal/ci-production-portal-frontend.Jenkinsfile similarity index 99% rename from fe/fe-portal/ci-beta-portal-frontend.Jenkinsfile rename to fe/fe-portal/ci-production-portal-frontend.Jenkinsfile index 533ded6..68e1c07 100644 --- a/fe/fe-portal/ci-beta-portal-frontend.Jenkinsfile +++ b/fe/fe-portal/ci-production-portal-frontend.Jenkinsfile @@ -11,7 +11,7 @@ pipeline { GIT_KTDT_BRANCH = 'beta_kinhtedothi' GIT_HNT_BRANCH = 'beta_hanoitimes' - ENV = 'beta' + ENV = 'production' PROJECT_NAME = 'portal' TRIGGER_JOB_NAME = 'CD-FE-PORTAL'