diff --git a/ansible/Jenkinsfile b/ansible/Jenkinsfile index 1c0d77a..80fc48b 100644 --- a/ansible/Jenkinsfile +++ b/ansible/Jenkinsfile @@ -13,22 +13,22 @@ pipeline { parameters { choice( name: 'DEPLOY_TARGET', - choices: ['SiteA', 'SiteB', 'All'], - description: 'Выберите сайты для развертывания' + choices: ['SiteA', 'SiteB', 'proxy', 'SiteA&proxy', 'SiteB&proxy', 'All'], + description: 'Выберите цели для развертывания' ) - string(name: 'ADDITIONAL_CONTENT_SITEA_H2', defaultValue: 'Новое сообщение для SiteA', description: 'Дополнительный
контент для SiteA') - - string(name: 'ADDITIONAL_CONTENT_SITEB_H2', defaultValue: 'Новое сообщение для SiteB', description: 'Дополнительный
контент для SiteB') + string( + name: 'ADDITIONAL_CONTENT', + defaultValue: 'Новое сообщение', + description: 'Дополнительный параграф' + ) } stages { stage('Decrypt SSH Key') { steps { script { - def tempDir = '/tmp/' + UUID.randomUUID().toString() + def tempDir = "/tmp/${UUID.randomUUID().toString()}" env.TEMP_DIR = tempDir sh "mkdir -p ${tempDir}" @@ -38,7 +38,7 @@ pipeline { writeFile file: vaultPassFile, text: VAULT_PASSWORD sh """ - ansible-vault decrypt ./ansible/id_ed25519_vault --output=${decryptedKeyFile} --vault-password-file=${vaultPassFile} + ansible-vault decrypt ./ansible/id_ed25519_vault --output=${decryptedKeyFile} --vault-password-file=${vaultPassFile} """ env.DECYPTED_KEY_FILE = decryptedKeyFile @@ -56,21 +56,34 @@ pipeline { switch(params.DEPLOY_TARGET) { case 'SiteA': - selectedHosts = 'SiteA,proxy' - extraVars.siteA_h2 = params.ADDITIONAL_CONTENT_SITEA_H2 - extraVars.siteA_p = params.ADDITIONAL_CONTENT_SITEA_P + selectedHosts = 'SiteA' + extraVars.siteA_h2 = params.ADDITIONAL_CONTENT + extraVars.siteA_p = params.ADDITIONAL_CONTENT break case 'SiteB': + selectedHosts = 'SiteB' + extraVars.siteB_h2 = params.ADDITIONAL_CONTENT + extraVars.siteB_p = params.ADDITIONAL_CONTENT + break + case 'proxy': + selectedHosts = 'proxy' + break + case 'SiteA&proxy': + selectedHosts = 'SiteA,proxy' + extraVars.siteA_h2 = params.ADDITIONAL_CONTENT + extraVars.siteA_p = params.ADDITIONAL_CONTENT + break + case 'SiteB&proxy': selectedHosts = 'SiteB,proxy' - extraVars.siteB_h2 = params.ADDITIONAL_CONTENT_SITEB_H2 - extraVars.siteB_p = params.ADDITIONAL_CONTENT_SITEB_P + extraVars.siteB_h2 = params.ADDITIONAL_CONTENT + extraVars.siteB_p = params.ADDITIONAL_CONTENT break case 'All': selectedHosts = 'SiteA,SiteB,proxy' - extraVars.siteA_h2 = params.ADDITIONAL_CONTENT_SITEA_H2 - extraVars.siteA_p = params.ADDITIONAL_CONTENT_SITEA_P - extraVars.siteB_h2 = params.ADDITIONAL_CONTENT_SITEB_H2 - extraVars.siteB_p = params.ADDITIONAL_CONTENT_SITEB_P + extraVars.siteA_h2 = params.ADDITIONAL_CONTENT + extraVars.siteA_p = params.ADDITIONAL_CONTENT + extraVars.siteB_h2 = params.ADDITIONAL_CONTENT + extraVars.siteB_p = params.ADDITIONAL_CONTENT break default: error "Неизвестный DEPLOY_TARGET: ${params.DEPLOY_TARGET}"