Thienvv - sửa cid theo ansible mới

This commit is contained in:
thienqb123456
2025-03-05 17:08:40 +07:00
parent c422a0caff
commit ef47b28f63
+25 -16
View File
@@ -1,7 +1,7 @@
pipeline { pipeline {
agent any agent any
parameters { 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 Portal') choice(name: 'PORTAL_NAME', choices: ['ktdt', 'hnt'], description: 'Choose Portal')
string(name: 'CI_JOB_BUILD_NUMBER', defaultValue: '', description: 'Build number of CI Job') string(name: 'CI_JOB_BUILD_NUMBER', defaultValue: '', description: 'Build number of CI Job')
} }
@@ -17,18 +17,36 @@ pipeline {
GIT_PAT_CREDENTIALS_ID = 'd3de261f-8f1e-470b-b6d1-2fb4965e0129' // Id của Personal Access Token lưu trên jenkins GIT_PAT_CREDENTIALS_ID = 'd3de261f-8f1e-470b-b6d1-2fb4965e0129' // Id của Personal Access Token lưu trên jenkins
GIT_ANSIBLE_URL = 'work.gct.com.vn/thienvv/nsg_ansible.git' GIT_ANSIBLE_URL = 'work.gct.com.vn/thienvv/nsg_ansible.git'
GIT_ANSIBLE_BRANCH = 'v2' GIT_ANSIBLE_BRANCH = 'v3'
ANSIBLE_FOLDER_PATH = '/srv/ansible_v3'
ANSIBLE_FOLDER_PATH = '/srv/ansible_v2'
ANSIBLE_INVENTORY_PATH = "inventory/${params.ENV}.ini"
ANSIBLE_PLAYBOOK_PATH = 'playbooks/deploy_be_resource.yml'
TELEGRAM_CHAT_ID = -4678013464 TELEGRAM_CHAT_ID = -4678013464
TELEGRAM_BOT_TOKEN = credentials('TELEGRAM_BOT_TOKEN') TELEGRAM_BOT_TOKEN = credentials('TELEGRAM_BOT_TOKEN')
} }
stages { 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/deploy_ktdt_resource_backend.yml'
} else if (params.PORTAL_NAME = 'hnt') {
env.ANSIBLE_PLAYBOOK_PATH = 'playbooks/deploy_hnt_resource_backend.yml'
}
echo "ANSIBLE_PLAYBOOK_PATH is set to: ${env.ANSIBLE_PLAYBOOK_PATH}"
}
}
}
stage('Retrieve Artifact Metadata From CI Job') { stage('Retrieve Artifact Metadata From CI Job') {
steps { steps {
script { script {
@@ -67,9 +85,6 @@ pipeline {
env.ANSIBLE_FOLDER_PATH, env.ANSIBLE_FOLDER_PATH,
env.ANSIBLE_INVENTORY_PATH, env.ANSIBLE_INVENTORY_PATH,
env.ANSIBLE_PLAYBOOK_PATH, env.ANSIBLE_PLAYBOOK_PATH,
params.ENV,
env.PROJECT_NAME,
params.PORTAL_NAME,
env.NEXUS_URL, env.NEXUS_URL,
env.NEXUS_ARTIFACT_NAME, env.NEXUS_ARTIFACT_NAME,
env.NEXUS_CREDENTIALS_USR, env.NEXUS_CREDENTIALS_USR,
@@ -193,9 +208,6 @@ def triggerAnsible(
String ansibleansibleFolderPath, String ansibleansibleFolderPath,
String inventoryPath, String inventoryPath,
String playbookPath, String playbookPath,
String deployENV,
String projectName,
String portalName,
String nexusUrl, String nexusUrl,
String nexusArtifactName, String nexusArtifactName,
String nexusUsername, String nexusUsername,
@@ -207,10 +219,7 @@ def triggerAnsible(
ssh ${sshAnsibleConnection} " ssh ${sshAnsibleConnection} "
cd ${ansibleansibleFolderPath} && cd ${ansibleansibleFolderPath} &&
ansible-playbook -i ${inventoryPath} ${playbookPath} \\ ansible-playbook -i ${inventoryPath} ${playbookPath} \\
-e 'deploy_env=${deployENV} \\ -e ' nexus_url=${nexusUrl} \\
project_name=${projectName} \\
portal_name=${portalName} \\
nexus_url=${nexusUrl} \\
artifact_name=${nexusArtifactName} \\ artifact_name=${nexusArtifactName} \\
nexus_username=${nexusUsername} \\ nexus_username=${nexusUsername} \\
nexus_password=${nexusPassword}' -vvvv nexus_password=${nexusPassword}' -vvvv