Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 1 | /** |
| 2 | * Generate cookiecutter cluster by individual products |
| 3 | * |
| 4 | * Expected parameters: |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 5 | * COOKIECUTTER_TEMPLATE_CONTEXT Context parameters for the template generation. |
Sergey Galkin | 8b87f6e | 2018-10-24 18:40:13 +0400 | [diff] [blame] | 6 | * CREDENTIALS_ID Credentials id for git |
azvyagintsev | 6d678da | 2018-11-28 21:19:06 +0200 | [diff] [blame] | 7 | * TEST_MODEL Run syntax tests for model |
azvyagintsev | 3ed704f | 2018-07-09 15:49:27 +0300 | [diff] [blame] | 8 | **/ |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 9 | import static groovy.json.JsonOutput.toJson |
| 10 | import static groovy.json.JsonOutput.prettyPrint |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 11 | |
| 12 | common = new com.mirantis.mk.Common() |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 13 | common2 = new com.mirantis.mcp.Common() |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 14 | git = new com.mirantis.mk.Git() |
| 15 | python = new com.mirantis.mk.Python() |
chnyda | 8919101 | 2017-05-29 15:38:35 +0200 | [diff] [blame] | 16 | saltModelTesting = new com.mirantis.mk.SaltModelTesting() |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 17 | |
azvyagintsev | aa7b43a | 2019-02-02 10:17:58 +0200 | [diff] [blame] | 18 | // slaveNode = env.getProperty('SLAVE_NODE') ?: 'python&&docker' |
| 19 | slaveNode = env.getProperty('SLAVE_NODE') ?: 'hardware' |
azvyagintsev | 6d678da | 2018-11-28 21:19:06 +0200 | [diff] [blame] | 20 | gerritCredentials = env.getProperty('CREDENTIALS_ID') ?: 'gerrit' |
| 21 | runTestModel = (env.getProperty('TEST_MODEL') ?: true).toBoolean() |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 22 | distribRevision = 'proposed' |
| 23 | gitGuessedVersion = false |
| 24 | |
| 25 | |
| 26 | def globalVariatorsUpdate() { |
| 27 | def templateContext = readYaml text: env.COOKIECUTTER_TEMPLATE_CONTEXT |
| 28 | def context = templateContext['default_context'] |
| 29 | // TODO add more check's for critical var's |
| 30 | // Since we can't pin to any '_branch' variable from context, to identify 'default git revision' - |
| 31 | // because each of them, might be 'refs/' variable, we need to add some tricky trigger of using |
| 32 | // 'release/XXX' logic. This is totall guess - so,if even those one failed, to definitely must pass |
| 33 | // correct variable finally! |
| 34 | [context.get('cookiecutter_template_branch'), context.get('shared_reclass_branch'), context.get('mcp_common_scripts_branch')].any { branch -> |
| 35 | if (branch.toString().startsWith('release/')) { |
| 36 | gitGuessedVersion = branch |
| 37 | return true |
| 38 | } |
| 39 | } |
Hanna Arhipova | d94612d | 2019-02-01 14:44:54 +0200 | [diff] [blame] | 40 | if ("${context['salt_master_hostname']}.${context['cluster_domain']}".length() > 64) { |
| 41 | common.errorMsg("Cluster domain has too long name. Make ${context['cluster_domain']} shorter than 58 symbols.") |
| 42 | error('Invalid context provided') |
| 43 | } |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 44 | // Use mcpVersion git tag if not specified branch for cookiecutter-templates |
| 45 | if (!context.get('cookiecutter_template_branch')) { |
| 46 | context['cookiecutter_template_branch'] = gitGuessedVersion ?: context['mcp_version'] |
| 47 | } |
| 48 | // Don't have n/t/s for cookiecutter-templates repo, therefore use master |
| 49 | if (["nightly", "testing", "stable"].contains(context['cookiecutter_template_branch'])) { |
| 50 | context['cookiecutter_template_branch'] = 'master' |
| 51 | } |
| 52 | if (!context.get('shared_reclass_branch')) { |
| 53 | context['shared_reclass_branch'] = gitGuessedVersion ?: context['mcp_version'] |
| 54 | } |
| 55 | // Don't have nightly/testing for reclass-system repo, therefore use master |
| 56 | if (["nightly", "testing", "stable"].contains(context['shared_reclass_branch'])) { |
| 57 | context['shared_reclass_branch'] = 'master' |
| 58 | } |
| 59 | if (!context.get('mcp_common_scripts_branch')) { |
| 60 | // Pin exactly to CC branch, since it might use 'release/XXX' format |
| 61 | context['mcp_common_scripts_branch'] = gitGuessedVersion ?: context['mcp_version'] |
| 62 | } |
| 63 | // Don't have n/t/s for mcp-common-scripts repo, therefore use master |
| 64 | if (["nightly", "testing", "stable"].contains(context['mcp_common_scripts_branch'])) { |
| 65 | context['mcp_common_scripts_branch'] = 'master' |
| 66 | } |
| 67 | // |
| 68 | distribRevision = context['mcp_version'] |
| 69 | if (['master'].contains(context['mcp_version'])) { |
| 70 | distribRevision = 'nightly' |
| 71 | } |
| 72 | if (distribRevision.contains('/')) { |
| 73 | distribRevision = distribRevision.split('/')[-1] |
| 74 | } |
| 75 | // Check if we are going to test bleeding-edge release, which doesn't have binary release yet |
azvyagintsev | 8e08164 | 2019-02-03 19:15:22 +0200 | [diff] [blame^] | 76 | // After 2018q4 releases, need to also check 'static' repo, for example ubuntu. |
| 77 | binTest = common.checkRemoteBinary(['mcp_version': distribRevision]) |
| 78 | if (!binTest.linux_system_repo_url || !binTest.linux_system_repo_ubuntu_url) { |
| 79 | common.errorMsg("Binary release: ${distribRevision} not exist or not full. Fallback to 'proposed'! ") |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 80 | distribRevision = 'proposed' |
| 81 | } |
azvyagintsev | 8e08164 | 2019-02-03 19:15:22 +0200 | [diff] [blame^] | 82 | |
azvyagintsev | 5400d1d | 2018-12-11 13:19:29 +0200 | [diff] [blame] | 83 | // (azvyagintsev) WA for PROD-25732 |
| 84 | if (context.cookiecutter_template_url.contains('gerrit.mcp.mirantis.com/mk/cookiecutter-templates')) { |
| 85 | common.warningMsg('Apply WA for PROD-25732') |
| 86 | context.cookiecutter_template_url = 'ssh://gerrit.mcp.mirantis.com:29418/mk/cookiecutter-templates.git' |
| 87 | } |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 88 | common.warningMsg("Fetching:\n" + |
| 89 | "DISTRIB_REVISION from ${distribRevision}") |
| 90 | common.infoMsg("Using context:\n" + context) |
| 91 | print prettyPrint(toJson(context)) |
| 92 | return context |
| 93 | |
| 94 | } |
azvyagintsev | f252b59 | 2018-08-13 18:39:14 +0300 | [diff] [blame] | 95 | |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 96 | timeout(time: 1, unit: 'HOURS') { |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame] | 97 | node(slaveNode) { |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 98 | def context = globalVariatorsUpdate() |
azvyagintsev | 6d678da | 2018-11-28 21:19:06 +0200 | [diff] [blame] | 99 | def RequesterEmail = context.get('email_address', '') |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 100 | def templateEnv = "${env.WORKSPACE}/template" |
| 101 | def modelEnv = "${env.WORKSPACE}/model" |
| 102 | def testEnv = "${env.WORKSPACE}/test" |
| 103 | def pipelineEnv = "${env.WORKSPACE}/pipelines" |
Tomáš Kukrál | 9f6260f | 2017-03-29 23:58:26 +0200 | [diff] [blame] | 104 | |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 105 | try { |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 106 | // |
| 107 | def cutterEnv = "${env.WORKSPACE}/cutter" |
| 108 | def systemEnv = "${modelEnv}/classes/system" |
| 109 | def testResult = false |
| 110 | def user |
| 111 | wrap([$class: 'BuildUser']) { |
| 112 | user = env.BUILD_USER_ID |
| 113 | } |
azvyagintsev | 6d678da | 2018-11-28 21:19:06 +0200 | [diff] [blame] | 114 | currentBuild.description = "${context['cluster_name']} ${RequesterEmail}" |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 115 | |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 116 | stage('Download Cookiecutter template') { |
| 117 | sh(script: 'find . -mindepth 1 -delete > /dev/null || true') |
| 118 | checkout([ |
| 119 | $class : 'GitSCM', |
| 120 | branches : [[name: 'FETCH_HEAD'],], |
| 121 | extensions : [[$class: 'RelativeTargetDirectory', relativeTargetDir: templateEnv]], |
| 122 | userRemoteConfigs: [[url: context['cookiecutter_template_url'], refspec: context['cookiecutter_template_branch'], credentialsId: gerritCredentials],], |
| 123 | ]) |
| 124 | } |
| 125 | stage('Create empty reclass model') { |
| 126 | dir(path: modelEnv) { |
| 127 | sh "rm -rfv .git; git init" |
| 128 | sshagent(credentials: [gerritCredentials]) { |
| 129 | sh "git submodule add ${context['shared_reclass_url']} 'classes/system'" |
| 130 | } |
| 131 | } |
| 132 | checkout([ |
| 133 | $class : 'GitSCM', |
| 134 | branches : [[name: 'FETCH_HEAD'],], |
| 135 | extensions : [[$class: 'RelativeTargetDirectory', relativeTargetDir: systemEnv]], |
| 136 | userRemoteConfigs: [[url: context['shared_reclass_url'], refspec: context['shared_reclass_branch'], credentialsId: gerritCredentials],], |
| 137 | ]) |
| 138 | git.commitGitChanges(modelEnv, "Added new shared reclass submodule", "${user}@localhost", "${user}") |
| 139 | } |
| 140 | |
| 141 | stage('Generate model') { |
Dmitry Pyzhov | 089fb4f | 2018-12-11 16:58:00 +0300 | [diff] [blame] | 142 | // GNUPGHOME environment variable is required for all gpg commands |
| 143 | // and for python.generateModel execution |
| 144 | withEnv(["GNUPGHOME=${env.WORKSPACE}/gpghome"]) { |
| 145 | if (context['secrets_encryption_enabled'] == 'True') { |
| 146 | sh "mkdir gpghome; chmod 700 gpghome" |
Dmitry Pyzhov | b5c74c7 | 2018-12-17 22:08:50 +0300 | [diff] [blame] | 147 | def secretKeyID = RequesterEmail ?: "salt@${context['cluster_domain']}".toString() |
Dmitry Pyzhov | 089fb4f | 2018-12-11 16:58:00 +0300 | [diff] [blame] | 148 | if (!context.get('secrets_encryption_private_key')) { |
| 149 | def batchData = """ |
| 150 | Key-Type: 1 |
| 151 | Key-Length: 4096 |
| 152 | Expire-Date: 0 |
| 153 | Name-Real: ${context['salt_master_hostname']}.${context['cluster_domain']} |
| 154 | Name-Email: ${secretKeyID} |
| 155 | """.stripIndent() |
| 156 | writeFile file:'gpg-batch.txt', text:batchData |
| 157 | sh "gpg --gen-key --batch < gpg-batch.txt" |
| 158 | sh "gpg --export-secret-key -a ${secretKeyID} > gpgkey.asc" |
| 159 | } else { |
| 160 | writeFile file:'gpgkey.asc', text:context['secrets_encryption_private_key'] |
| 161 | sh "gpg --import gpgkey.asc" |
| 162 | secretKeyID = sh(returnStdout: true, script: 'gpg --list-secret-keys --with-colons | awk -F: -e "/^sec/{print \\$5; exit}"').trim() |
| 163 | } |
| 164 | context['secrets_encryption_key_id'] = secretKeyID |
| 165 | } |
Stanislav Riazanov | da45ea0 | 2018-12-21 16:12:50 +0400 | [diff] [blame] | 166 | if (context.get('cfg_failsafe_ssh_public_key')) { |
| 167 | writeFile file:'failsafe-ssh-key.pub', text:context['cfg_failsafe_ssh_public_key'] |
| 168 | } |
Dmitry Pyzhov | 089fb4f | 2018-12-11 16:58:00 +0300 | [diff] [blame] | 169 | python.setupCookiecutterVirtualenv(cutterEnv) |
| 170 | // FIXME refactor generateModel |
| 171 | python.generateModel(common2.dumpYAML(['default_context': context]), 'default_context', context['salt_master_hostname'], cutterEnv, modelEnv, templateEnv, false) |
| 172 | git.commitGitChanges(modelEnv, "Create model ${context['cluster_name']}", "${user}@localhost", "${user}") |
| 173 | } |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | stage("Test") { |
azvyagintsev | 6d678da | 2018-11-28 21:19:06 +0200 | [diff] [blame] | 177 | if (runTestModel) { |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 178 | sh("cp -r ${modelEnv} ${testEnv}") |
| 179 | def DockerCName = "${env.JOB_NAME.toLowerCase()}_${env.BUILD_TAG.toLowerCase()}" |
| 180 | common.infoMsg("Attempt to run test against distribRevision: ${distribRevision}") |
| 181 | try { |
| 182 | def config = [ |
| 183 | 'dockerHostname' : "${context['salt_master_hostname']}.${context['cluster_domain']}", |
| 184 | 'reclassEnv' : testEnv, |
| 185 | 'distribRevision' : distribRevision, |
| 186 | 'dockerContainerName': DockerCName, |
| 187 | 'testContext' : 'salt-model-node' |
| 188 | ] |
| 189 | testResult = saltModelTesting.testNode(config) |
| 190 | common.infoMsg("Test finished: SUCCESS") |
| 191 | } catch (Exception ex) { |
| 192 | common.warningMsg("Test finished: FAILED") |
| 193 | testResult = false |
| 194 | } |
| 195 | } else { |
| 196 | common.warningMsg("Test stage has been skipped!") |
| 197 | } |
| 198 | } |
| 199 | stage("Generate config drives") { |
| 200 | // apt package genisoimage is required for this stage |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 201 | // download create-config-drive |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 202 | def commonScriptsRepoUrl = context['mcp_common_scripts_repo'] ?: 'ssh://gerrit.mcp.mirantis.com:29418/mcp/mcp-common-scripts' |
| 203 | checkout([ |
| 204 | $class : 'GitSCM', |
| 205 | branches : [[name: 'FETCH_HEAD'],], |
| 206 | extensions : [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'mcp-common-scripts']], |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 207 | userRemoteConfigs: [[url: commonScriptsRepoUrl, refspec: context['mcp_common_scripts_branch'], credentialsId: gerritCredentials],], |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 208 | ]) |
| 209 | |
| 210 | sh 'cp mcp-common-scripts/config-drive/create_config_drive.sh create-config-drive && chmod +x create-config-drive' |
| 211 | sh '[ -f mcp-common-scripts/config-drive/master_config.sh ] && cp mcp-common-scripts/config-drive/master_config.sh user_data || cp mcp-common-scripts/config-drive/master_config.yaml user_data' |
| 212 | |
| 213 | sh "git clone --mirror https://github.com/Mirantis/mk-pipelines.git ${pipelineEnv}/mk-pipelines" |
| 214 | sh "git clone --mirror https://github.com/Mirantis/pipeline-library.git ${pipelineEnv}/pipeline-library" |
| 215 | args = "--user-data user_data --hostname ${context['salt_master_hostname']} --model ${modelEnv} --mk-pipelines ${pipelineEnv}/mk-pipelines/ --pipeline-library ${pipelineEnv}/pipeline-library/ ${context['salt_master_hostname']}.${context['cluster_domain']}-config.iso" |
Dmitry Pyzhov | 089fb4f | 2018-12-11 16:58:00 +0300 | [diff] [blame] | 216 | if (context['secrets_encryption_enabled'] == 'True') { |
| 217 | args = "--gpg-key gpgkey.asc " + args |
| 218 | } |
Stanislav Riazanov | da45ea0 | 2018-12-21 16:12:50 +0400 | [diff] [blame] | 219 | if (context.get('cfg_failsafe_ssh_public_key')) { |
| 220 | args = "--ssh-key failsafe-ssh-key.pub " + args |
| 221 | } |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 222 | |
| 223 | // load data from model |
| 224 | def smc = [:] |
| 225 | smc['SALT_MASTER_MINION_ID'] = "${context['salt_master_hostname']}.${context['cluster_domain']}" |
| 226 | smc['SALT_MASTER_DEPLOY_IP'] = context['salt_master_management_address'] |
| 227 | smc['DEPLOY_NETWORK_GW'] = context['deploy_network_gateway'] |
| 228 | smc['DEPLOY_NETWORK_NETMASK'] = context['deploy_network_netmask'] |
| 229 | if (context.get('deploy_network_mtu')) { |
| 230 | smc['DEPLOY_NETWORK_MTU'] = context['deploy_network_mtu'] |
| 231 | } |
| 232 | smc['DNS_SERVERS'] = context['dns_server01'] |
| 233 | smc['MCP_VERSION'] = "${context['mcp_version']}" |
| 234 | if (context['local_repositories'] == 'True') { |
| 235 | def localRepoIP = context['local_repo_url'] |
| 236 | smc['MCP_SALT_REPO_KEY'] = "http://${localRepoIP}/public.gpg" |
| 237 | smc['MCP_SALT_REPO_URL'] = "http://${localRepoIP}/ubuntu-xenial" |
| 238 | smc['PIPELINES_FROM_ISO'] = 'false' |
| 239 | smc['PIPELINE_REPO_URL'] = "http://${localRepoIP}:8088" |
| 240 | smc['LOCAL_REPOS'] = 'true' |
| 241 | } |
| 242 | if (context['upstream_proxy_enabled'] == 'True') { |
| 243 | if (context['upstream_proxy_auth_enabled'] == 'True') { |
| 244 | smc['http_proxy'] = 'http://' + context['upstream_proxy_user'] + ':' + context['upstream_proxy_password'] + '@' + context['upstream_proxy_address'] + ':' + context['upstream_proxy_port'] |
| 245 | smc['https_proxy'] = 'http://' + context['upstream_proxy_user'] + ':' + context['upstream_proxy_password'] + '@' + context['upstream_proxy_address'] + ':' + context['upstream_proxy_port'] |
| 246 | } else { |
| 247 | smc['http_proxy'] = 'http://' + context['upstream_proxy_address'] + ':' + context['upstream_proxy_port'] |
| 248 | smc['https_proxy'] = 'http://' + context['upstream_proxy_address'] + ':' + context['upstream_proxy_port'] |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | for (i in common.entries(smc)) { |
| 253 | sh "sed -i 's,${i[0]}=.*,${i[0]}=${i[1]},' user_data" |
| 254 | } |
| 255 | |
| 256 | // create cfg config-drive |
| 257 | sh "./create-config-drive ${args}" |
| 258 | sh("mkdir output-${context['cluster_name']} && mv ${context['salt_master_hostname']}.${context['cluster_domain']}-config.iso output-${context['cluster_name']}/") |
| 259 | |
| 260 | // save cfg iso to artifacts |
| 261 | archiveArtifacts artifacts: "output-${context['cluster_name']}/${context['salt_master_hostname']}.${context['cluster_domain']}-config.iso" |
| 262 | |
| 263 | if (context['local_repositories'] == 'True') { |
| 264 | def aptlyServerHostname = context.aptly_server_hostname |
| 265 | sh "[ -f mcp-common-scripts/config-drive/mirror_config.yaml ] && cp mcp-common-scripts/config-drive/mirror_config.yaml mirror_config || cp mcp-common-scripts/config-drive/mirror_config.sh mirror_config" |
| 266 | |
| 267 | def smc_apt = [:] |
| 268 | smc_apt['SALT_MASTER_DEPLOY_IP'] = context['salt_master_management_address'] |
| 269 | smc_apt['APTLY_DEPLOY_IP'] = context['aptly_server_deploy_address'] |
| 270 | smc_apt['APTLY_DEPLOY_NETMASK'] = context['deploy_network_netmask'] |
| 271 | smc_apt['APTLY_MINION_ID'] = "${aptlyServerHostname}.${context['cluster_domain']}" |
| 272 | |
| 273 | for (i in common.entries(smc_apt)) { |
| 274 | sh "sed -i \"s,export ${i[0]}=.*,export ${i[0]}=${i[1]},\" mirror_config" |
| 275 | } |
| 276 | |
| 277 | // create apt config-drive |
| 278 | sh "./create-config-drive --user-data mirror_config --hostname ${aptlyServerHostname} ${aptlyServerHostname}.${context['cluster_domain']}-config.iso" |
| 279 | sh("mv ${aptlyServerHostname}.${context['cluster_domain']}-config.iso output-${context['cluster_name']}/") |
| 280 | |
| 281 | // save apt iso to artifacts |
| 282 | archiveArtifacts artifacts: "output-${context['cluster_name']}/${aptlyServerHostname}.${context['cluster_domain']}-config.iso" |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | stage('Save changes reclass model') { |
| 287 | sh(returnStatus: true, script: "tar -czf output-${context['cluster_name']}/${context['cluster_name']}.tar.gz --exclude='*@tmp' -C ${modelEnv} .") |
| 288 | archiveArtifacts artifacts: "output-${context['cluster_name']}/${context['cluster_name']}.tar.gz" |
| 289 | |
azvyagintsev | 5400d1d | 2018-12-11 13:19:29 +0200 | [diff] [blame] | 290 | if (RequesterEmail != '' && !RequesterEmail.contains('example')) { |
azvyagintsev | 6d678da | 2018-11-28 21:19:06 +0200 | [diff] [blame] | 291 | emailext(to: RequesterEmail, |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 292 | attachmentsPattern: "output-${context['cluster_name']}/*", |
| 293 | body: "Mirantis Jenkins\n\nRequested reclass model ${context['cluster_name']} has been created and attached to this email.\nEnjoy!\n\nMirantis", |
| 294 | subject: "Your Salt model ${context['cluster_name']}") |
| 295 | } |
| 296 | dir("output-${context['cluster_name']}") { |
| 297 | deleteDir() |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | // Fail, but leave possibility to get failed artifacts |
azvyagintsev | 6d678da | 2018-11-28 21:19:06 +0200 | [diff] [blame] | 302 | if (!testResult && runTestModel) { |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 303 | common.warningMsg('Test finished: FAILURE. Please check logs and\\or debug failed model manually!') |
| 304 | error('Test stage finished: FAILURE') |
| 305 | } |
| 306 | |
| 307 | } catch (Throwable e) { |
| 308 | currentBuild.result = "FAILURE" |
| 309 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 310 | throw e |
| 311 | } finally { |
| 312 | stage('Clean workspace directories') { |
| 313 | sh(script: 'find . -mindepth 1 -delete > /dev/null || true') |
| 314 | } |
| 315 | // common.sendNotification(currentBuild.result,"",["slack"]) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 316 | } |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 317 | } |
Mikhail Ivanov | 9f81292 | 2017-11-07 18:52:02 +0400 | [diff] [blame] | 318 | } |