Thienvv - sửa cid theo ansible mới
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
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 Portal')
|
||||
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_ANSIBLE_URL = 'work.gct.com.vn/thienvv/nsg_ansible.git'
|
||||
GIT_ANSIBLE_BRANCH = 'v2'
|
||||
GIT_ANSIBLE_BRANCH = 'v3'
|
||||
|
||||
|
||||
ANSIBLE_FOLDER_PATH = '/srv/ansible_v2'
|
||||
ANSIBLE_INVENTORY_PATH = "inventory/${params.ENV}.ini"
|
||||
ANSIBLE_PLAYBOOK_PATH = 'playbooks/deploy_be_resource.yml'
|
||||
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/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') {
|
||||
steps {
|
||||
script {
|
||||
@@ -67,9 +85,6 @@ pipeline {
|
||||
env.ANSIBLE_FOLDER_PATH,
|
||||
env.ANSIBLE_INVENTORY_PATH,
|
||||
env.ANSIBLE_PLAYBOOK_PATH,
|
||||
params.ENV,
|
||||
env.PROJECT_NAME,
|
||||
params.PORTAL_NAME,
|
||||
env.NEXUS_URL,
|
||||
env.NEXUS_ARTIFACT_NAME,
|
||||
env.NEXUS_CREDENTIALS_USR,
|
||||
@@ -193,9 +208,6 @@ def triggerAnsible(
|
||||
String ansibleansibleFolderPath,
|
||||
String inventoryPath,
|
||||
String playbookPath,
|
||||
String deployENV,
|
||||
String projectName,
|
||||
String portalName,
|
||||
String nexusUrl,
|
||||
String nexusArtifactName,
|
||||
String nexusUsername,
|
||||
@@ -207,10 +219,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
|
||||
|
||||
Reference in New Issue
Block a user