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. |
Tomáš Kukrál | 91e4925 | 2017-05-09 14:40:26 +0200 | [diff] [blame] | 6 | * EMAIL_ADDRESS Email to send a created tar file |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 7 | * |
azvyagintsev | 3ed704f | 2018-07-09 15:49:27 +0300 | [diff] [blame] | 8 | **/ |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 9 | |
| 10 | common = new com.mirantis.mk.Common() |
| 11 | git = new com.mirantis.mk.Git() |
| 12 | python = new com.mirantis.mk.Python() |
chnyda | 8919101 | 2017-05-29 15:38:35 +0200 | [diff] [blame] | 13 | saltModelTesting = new com.mirantis.mk.SaltModelTesting() |
Tomáš Kukrál | cebc1a0 | 2017-07-25 16:10:37 +0200 | [diff] [blame] | 14 | ssh = new com.mirantis.mk.Ssh() |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 15 | |
Vasyl Saienko | 682043d | 2018-07-23 16:04:10 +0300 | [diff] [blame] | 16 | def reclassVersion = 'v1.5.4' |
Vasyl Saienko | 772e123 | 2018-07-23 14:42:24 +0300 | [diff] [blame] | 17 | if (common.validInputParam('RECLASS_VERSION')) { |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 18 | reclassVersion = RECLASS_VERSION |
Vasyl Saienko | 772e123 | 2018-07-23 14:42:24 +0300 | [diff] [blame] | 19 | } |
azvyagintsev | f252b59 | 2018-08-13 18:39:14 +0300 | [diff] [blame] | 20 | slaveNode = (env.SLAVE_NODE ?: 'python&&docker') |
Vasyl Saienko | 772e123 | 2018-07-23 14:42:24 +0300 | [diff] [blame] | 21 | |
azvyagintsev | f252b59 | 2018-08-13 18:39:14 +0300 | [diff] [blame] | 22 | // install extra formulas required only for rendering cfg01. All others - should be fetched automatically via |
| 23 | // salt.master.env state, during salt-master bootstrap. |
| 24 | // TODO: In the best - those data should fetched somewhere from CC, per env\context. Like option, process _enabled |
| 25 | // options from CC contexts |
| 26 | // currently, just mix them together in one set |
| 27 | def testCfg01ExtraFormulas = 'glusterfs jenkins logrotate maas ntp rsyslog fluentd telegraf prometheus ' + |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 28 | 'grafana backupninja' |
azvyagintsev | f252b59 | 2018-08-13 18:39:14 +0300 | [diff] [blame] | 29 | |
| 30 | |
| 31 | timeout(time: 2, unit: 'HOURS') { |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 32 | node(slaveNode) { |
| 33 | def templateEnv = "${env.WORKSPACE}/template" |
| 34 | def modelEnv = "${env.WORKSPACE}/model" |
| 35 | def testEnv = "${env.WORKSPACE}/test" |
| 36 | def pipelineEnv = "${env.WORKSPACE}/pipelines" |
Tomáš Kukrál | 9f6260f | 2017-03-29 23:58:26 +0200 | [diff] [blame] | 37 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 38 | try { |
| 39 | def templateContext = readYaml text: COOKIECUTTER_TEMPLATE_CONTEXT |
| 40 | def mcpVersion = templateContext.default_context.mcp_version |
| 41 | def sharedReclassUrl = templateContext.default_context.shared_reclass_url |
| 42 | def clusterDomain = templateContext.default_context.cluster_domain |
| 43 | def clusterName = templateContext.default_context.cluster_name |
| 44 | def saltMaster = templateContext.default_context.salt_master_hostname |
| 45 | def localRepositories = templateContext.default_context.local_repositories.toBoolean() |
| 46 | def offlineDeployment = templateContext.default_context.offline_deployment.toBoolean() |
| 47 | def cutterEnv = "${env.WORKSPACE}/cutter" |
| 48 | def jinjaEnv = "${env.WORKSPACE}/jinja" |
| 49 | def outputDestination = "${modelEnv}/classes/cluster/${clusterName}" |
| 50 | def systemEnv = "${modelEnv}/classes/system" |
| 51 | def targetBranch = "feature/${clusterName}" |
| 52 | def templateBaseDir = "${env.WORKSPACE}/template" |
| 53 | def templateDir = "${templateEnv}/template/dir" |
| 54 | def templateOutputDir = templateBaseDir |
| 55 | def user |
| 56 | def testResult = false |
| 57 | wrap([$class: 'BuildUser']) { |
| 58 | user = env.BUILD_USER_ID |
Tomáš Kukrál | a3f4ba7 | 2017-08-03 15:40:22 +0200 | [diff] [blame] | 59 | } |
| 60 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 61 | if (mcpVersion != '2018.4.0') { |
| 62 | testCfg01ExtraFormulas += ' auditd' |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 63 | } |
| 64 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 65 | currentBuild.description = clusterName |
| 66 | print("Using context:\n" + COOKIECUTTER_TEMPLATE_CONTEXT) |
Richard Felkl | e77b091 | 2018-01-31 17:12:23 +0100 | [diff] [blame] | 67 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 68 | stage('Download Cookiecutter template') { |
| 69 | sh(script: 'find . -mindepth 1 -delete > /dev/null || true') |
| 70 | def cookiecutterTemplateUrl = templateContext.default_context.cookiecutter_template_url |
| 71 | def cookiecutterTemplateBranch = templateContext.default_context.cookiecutter_template_branch |
| 72 | git.checkoutGitRepository(templateEnv, cookiecutterTemplateUrl, 'master') |
| 73 | // Use refspec if exists first of all |
| 74 | if (cookiecutterTemplateBranch.toString().startsWith('refs/')) { |
| 75 | dir(templateEnv) { |
| 76 | ssh.agentSh("git fetch ${cookiecutterTemplateUrl} ${cookiecutterTemplateBranch} && git checkout FETCH_HEAD") |
| 77 | } |
| 78 | } else { |
| 79 | // Use mcpVersion git tag if not specified branch for cookiecutter-templates |
| 80 | if (cookiecutterTemplateBranch == '') { |
| 81 | cookiecutterTemplateBranch = mcpVersion |
| 82 | // Don't have nightly/testing/stable for cookiecutter-templates repo, therefore use master |
| 83 | if (["nightly", "testing", "stable"].contains(mcpVersion)) { |
| 84 | cookiecutterTemplateBranch = 'master' |
| 85 | } |
| 86 | } |
| 87 | git.changeGitBranch(templateEnv, cookiecutterTemplateBranch) |
| 88 | } |
| 89 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 90 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 91 | stage('Create empty reclass model') { |
| 92 | dir(path: modelEnv) { |
| 93 | sh "rm -rfv .git" |
| 94 | sh "git init" |
| 95 | ssh.agentSh("git submodule add ${sharedReclassUrl} 'classes/system'") |
| 96 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 97 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 98 | def sharedReclassBranch = templateContext.default_context.shared_reclass_branch |
| 99 | // Use refspec if exists first of all |
| 100 | if (sharedReclassBranch.toString().startsWith('refs/')) { |
| 101 | dir(systemEnv) { |
| 102 | ssh.agentSh("git fetch ${sharedReclassUrl} ${sharedReclassBranch} && git checkout FETCH_HEAD") |
| 103 | } |
| 104 | } else { |
| 105 | // Use mcpVersion git tag if not specified branch for reclass-system |
| 106 | if (sharedReclassBranch == '') { |
| 107 | sharedReclassBranch = mcpVersion |
| 108 | // Don't have nightly/testing for reclass-system repo, therefore use master |
| 109 | if (["nightly", "testing", "stable"].contains(mcpVersion)) { |
| 110 | common.warningMsg("Fetching reclass-system from master!") |
| 111 | sharedReclassBranch = 'master' |
| 112 | } |
| 113 | } |
| 114 | git.changeGitBranch(systemEnv, sharedReclassBranch) |
| 115 | } |
| 116 | git.commitGitChanges(modelEnv, "Added new shared reclass submodule", "${user}@localhost", "${user}") |
| 117 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 118 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 119 | def productList = ["infra", "cicd", "opencontrail", "kubernetes", "openstack", "oss", "stacklight", "ceph"] |
| 120 | for (product in productList) { |
Richard Felkl | 9543faa | 2018-01-11 09:47:35 +0100 | [diff] [blame] | 121 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 122 | // get templateOutputDir and productDir |
| 123 | if (product.startsWith("stacklight")) { |
| 124 | templateOutputDir = "${env.WORKSPACE}/output/stacklight" |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 125 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 126 | def stacklightVersion |
| 127 | try { |
| 128 | stacklightVersion = templateContext.default_context['stacklight_version'] |
| 129 | } catch (Throwable e) { |
| 130 | common.warningMsg('Stacklight version loading failed') |
| 131 | } |
Tomáš Kukrál | a3f4ba7 | 2017-08-03 15:40:22 +0200 | [diff] [blame] | 132 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 133 | if (stacklightVersion) { |
| 134 | productDir = "stacklight" + stacklightVersion |
| 135 | } else { |
| 136 | productDir = "stacklight1" |
| 137 | } |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 138 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 139 | } else { |
| 140 | templateOutputDir = "${env.WORKSPACE}/output/${product}" |
| 141 | productDir = product |
| 142 | } |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 143 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 144 | if (product == "infra" || (templateContext.default_context["${product}_enabled"] |
| 145 | && templateContext.default_context["${product}_enabled"].toBoolean())) { |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 146 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 147 | templateDir = "${templateEnv}/cluster_product/${productDir}" |
| 148 | common.infoMsg("Generating product " + product + " from " + templateDir + " to " + templateOutputDir) |
| 149 | |
| 150 | sh "rm -rf ${templateOutputDir} || true" |
| 151 | sh "mkdir -p ${templateOutputDir}" |
| 152 | sh "mkdir -p ${outputDestination}" |
| 153 | |
| 154 | python.setupCookiecutterVirtualenv(cutterEnv) |
| 155 | python.buildCookiecutterTemplate(templateDir, COOKIECUTTER_TEMPLATE_CONTEXT, templateOutputDir, cutterEnv, templateBaseDir) |
| 156 | sh "mv -v ${templateOutputDir}/${clusterName}/* ${outputDestination}" |
| 157 | } else { |
| 158 | common.warningMsg("Product " + product + " is disabled") |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | if (localRepositories && !offlineDeployment) { |
| 163 | def aptlyModelUrl = templateContext.default_context.local_model_url |
| 164 | dir(path: modelEnv) { |
| 165 | ssh.agentSh "git submodule add \"${aptlyModelUrl}\" \"classes/cluster/${clusterName}/cicd/aptly\"" |
| 166 | if (!(mcpVersion in ["nightly", "testing", "stable"])) { |
| 167 | ssh.agentSh "cd \"classes/cluster/${clusterName}/cicd/aptly\";git fetch --tags;git checkout ${mcpVersion}" |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | stage('Generate new SaltMaster node') { |
| 173 | def nodeFile = "${modelEnv}/nodes/${saltMaster}.${clusterDomain}.yml" |
| 174 | def nodeString = """classes: |
Leontii Istomin | 56b6b11 | 2018-01-15 12:14:24 +0300 | [diff] [blame] | 175 | - cluster.${clusterName}.infra.config |
| 176 | parameters: |
| 177 | _param: |
| 178 | linux_system_codename: xenial |
| 179 | reclass_data_revision: master |
| 180 | linux: |
| 181 | system: |
| 182 | name: ${saltMaster} |
| 183 | domain: ${clusterDomain} |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 184 | """ |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 185 | sh "mkdir -p ${modelEnv}/nodes/" |
| 186 | writeFile(file: nodeFile, text: nodeString) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 187 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 188 | git.commitGitChanges(modelEnv, "Create model ${clusterName}", "${user}@localhost", "${user}") |
| 189 | } |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 190 | |
azvyagintsev | 636493c | 2018-09-12 17:17:05 +0300 | [diff] [blame^] | 191 | stage("Test") { |
| 192 | if (TEST_MODEL.toBoolean() && sharedReclassUrl != '') { |
| 193 | sh("cp -r ${modelEnv} ${testEnv}") |
| 194 | def DockerCName = "${env.JOB_NAME.toLowerCase()}_${env.BUILD_TAG.toLowerCase()}" |
| 195 | common.infoMsg("Attempt to run test against formula-version: ${mcpVersion}") |
| 196 | testResult = saltModelTesting.setupAndTestNode( |
| 197 | "${saltMaster}.${clusterDomain}", |
| 198 | "", |
| 199 | testCfg01ExtraFormulas, |
| 200 | testEnv, |
| 201 | 'pkg', |
| 202 | mcpVersion, |
| 203 | reclassVersion, |
| 204 | 0, |
| 205 | false, |
| 206 | false, |
| 207 | '', |
| 208 | '', |
| 209 | DockerCName) |
| 210 | if (testResult) { |
| 211 | common.infoMsg("Test finished: SUCCESS") |
| 212 | } else { |
| 213 | common.warningMsg('Test finished: FAILURE') |
| 214 | } |
| 215 | } else { |
| 216 | common.warningMsg("Test stage has been skipped!") |
| 217 | } |
| 218 | } |
| 219 | stage("Generate config drives") { |
| 220 | // apt package genisoimage is required for this stage |
| 221 | |
| 222 | // download create-config-drive |
| 223 | // FIXME: that should be refactored, to use git clone - to be able download it from custom repo. |
| 224 | def mcpCommonScriptsBranch = templateContext.default_context.mcp_common_scripts_branch |
| 225 | if (mcpCommonScriptsBranch == '') { |
| 226 | mcpCommonScriptsBranch = mcpVersion |
| 227 | // Don't have n/t/s for mcp-common-scripts repo, therefore use master |
| 228 | if (["nightly", "testing", "stable"].contains(mcpVersion)) { |
| 229 | common.warningMsg("Fetching mcp-common-scripts from master!") |
| 230 | mcpCommonScriptsBranch = 'master' |
| 231 | } |
| 232 | } |
| 233 | def config_drive_script_url = "https://raw.githubusercontent.com/Mirantis/mcp-common-scripts/${mcpCommonScriptsBranch}/config-drive/create_config_drive.sh" |
| 234 | def user_data_script_url = "https://raw.githubusercontent.com/Mirantis/mcp-common-scripts/${mcpCommonScriptsBranch}/config-drive/master_config.sh" |
| 235 | common.retry(3, 5) { |
| 236 | sh "wget -O create-config-drive ${config_drive_script_url} && chmod +x create-config-drive" |
| 237 | sh "wget -O user_data.sh ${user_data_script_url}" |
| 238 | } |
| 239 | |
| 240 | sh "git clone --mirror https://github.com/Mirantis/mk-pipelines.git ${pipelineEnv}/mk-pipelines" |
| 241 | sh "git clone --mirror https://github.com/Mirantis/pipeline-library.git ${pipelineEnv}/pipeline-library" |
| 242 | args = "--user-data user_data.sh --hostname ${saltMaster} --model ${modelEnv} --mk-pipelines ${pipelineEnv}/mk-pipelines/ --pipeline-library ${pipelineEnv}/pipeline-library/ ${saltMaster}.${clusterDomain}-config.iso" |
| 243 | |
| 244 | // load data from model |
| 245 | def smc = [:] |
| 246 | smc['SALT_MASTER_MINION_ID'] = "${saltMaster}.${clusterDomain}" |
| 247 | smc['SALT_MASTER_DEPLOY_IP'] = templateContext['default_context']['salt_master_management_address'] |
| 248 | smc['DEPLOY_NETWORK_GW'] = templateContext['default_context']['deploy_network_gateway'] |
| 249 | smc['DEPLOY_NETWORK_NETMASK'] = templateContext['default_context']['deploy_network_netmask'] |
| 250 | if (templateContext['default_context'].get('deploy_network_mtu')) { |
| 251 | smc['DEPLOY_NETWORK_MTU'] = templateContext['default_context']['deploy_network_mtu'] |
| 252 | } |
| 253 | smc['DNS_SERVERS'] = templateContext['default_context']['dns_server01'] |
| 254 | smc['MCP_VERSION'] = "${mcpVersion}" |
| 255 | if (templateContext['default_context']['local_repositories'] == 'True') { |
| 256 | def localRepoIP = templateContext['default_context']['local_repo_url'] |
| 257 | smc['MCP_SALT_REPO_KEY'] = "http://${localRepoIP}/public.gpg" |
| 258 | smc['MCP_SALT_REPO_URL'] = "http://${localRepoIP}/ubuntu-xenial" |
| 259 | smc['PIPELINES_FROM_ISO'] = 'false' |
| 260 | smc['PIPELINE_REPO_URL'] = "http://${localRepoIP}:8088" |
| 261 | smc['LOCAL_REPOS'] = 'true' |
| 262 | } |
| 263 | if (templateContext['default_context']['upstream_proxy_enabled'] == 'True') { |
| 264 | if (templateContext['default_context']['upstream_proxy_auth_enabled'] == 'True') { |
| 265 | smc['http_proxy'] = 'http://' + templateContext['default_context']['upstream_proxy_user'] + ':' + templateContext['default_context']['upstream_proxy_password'] + '@' + templateContext['default_context']['upstream_proxy_address'] + ':' + templateContext['default_context']['upstream_proxy_port'] |
| 266 | smc['https_proxy'] = 'http://' + templateContext['default_context']['upstream_proxy_user'] + ':' + templateContext['default_context']['upstream_proxy_password'] + '@' + templateContext['default_context']['upstream_proxy_address'] + ':' + templateContext['default_context']['upstream_proxy_port'] |
| 267 | } else { |
| 268 | smc['http_proxy'] = 'http://' + templateContext['default_context']['upstream_proxy_address'] + ':' + templateContext['default_context']['upstream_proxy_port'] |
| 269 | smc['https_proxy'] = 'http://' + templateContext['default_context']['upstream_proxy_address'] + ':' + templateContext['default_context']['upstream_proxy_port'] |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | for (i in common.entries(smc)) { |
| 274 | sh "sed -i 's,export ${i[0]}=.*,export ${i[0]}=${i[1]},' user_data.sh" |
| 275 | } |
| 276 | |
| 277 | // create cfg config-drive |
| 278 | sh "./create-config-drive ${args}" |
| 279 | sh("mkdir output-${clusterName} && mv ${saltMaster}.${clusterDomain}-config.iso output-${clusterName}/") |
| 280 | |
| 281 | // save cfg iso to artifacts |
| 282 | archiveArtifacts artifacts: "output-${clusterName}/${saltMaster}.${clusterDomain}-config.iso" |
| 283 | |
| 284 | if (templateContext['default_context']['local_repositories'] == 'True') { |
| 285 | def aptlyServerHostname = templateContext.default_context.aptly_server_hostname |
| 286 | def user_data_script_apt_url = "https://raw.githubusercontent.com/Mirantis/mcp-common-scripts/master/config-drive/mirror_config.sh" |
| 287 | sh "wget -O mirror_config.sh ${user_data_script_apt_url}" |
| 288 | |
| 289 | def smc_apt = [:] |
| 290 | smc_apt['SALT_MASTER_DEPLOY_IP'] = templateContext['default_context']['salt_master_management_address'] |
| 291 | smc_apt['APTLY_DEPLOY_IP'] = templateContext['default_context']['aptly_server_deploy_address'] |
| 292 | smc_apt['APTLY_DEPLOY_NETMASK'] = templateContext['default_context']['deploy_network_netmask'] |
| 293 | smc_apt['APTLY_MINION_ID'] = "${aptlyServerHostname}.${clusterDomain}" |
| 294 | |
| 295 | for (i in common.entries(smc_apt)) { |
| 296 | sh "sed -i \"s,export ${i[0]}=.*,export ${i[0]}=${i[1]},\" mirror_config.sh" |
| 297 | } |
| 298 | |
| 299 | // create apt config-drive |
| 300 | sh "./create-config-drive --user-data mirror_config.sh --hostname ${aptlyServerHostname} ${aptlyServerHostname}.${clusterDomain}-config.iso" |
| 301 | sh("mv ${aptlyServerHostname}.${clusterDomain}-config.iso output-${clusterName}/") |
| 302 | |
| 303 | // save apt iso to artifacts |
| 304 | archiveArtifacts artifacts: "output-${clusterName}/${aptlyServerHostname}.${clusterDomain}-config.iso" |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | stage('Save changes reclass model') { |
| 309 | sh(returnStatus: true, script: "tar -czf output-${clusterName}/${clusterName}.tar.gz --exclude='*@tmp' -C ${modelEnv} .") |
| 310 | archiveArtifacts artifacts: "output-${clusterName}/${clusterName}.tar.gz" |
| 311 | |
| 312 | |
| 313 | if (EMAIL_ADDRESS != null && EMAIL_ADDRESS != "") { |
| 314 | emailext(to: EMAIL_ADDRESS, |
| 315 | attachmentsPattern: "output-${clusterName}/*", |
| 316 | body: "Mirantis Jenkins\n\nRequested reclass model ${clusterName} has been created and attached to this email.\nEnjoy!\n\nMirantis", |
| 317 | subject: "Your Salt model ${clusterName}") |
| 318 | } |
| 319 | dir("output-${clusterName}") { |
| 320 | deleteDir() |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | // Fail, but leave possibility to get failed artifacts |
| 325 | if (!testResult && TEST_MODEL.toBoolean()) { |
| 326 | common.warningMsg('Test finished: FAILURE. Please check logs and\\or debug failed model manually!') |
| 327 | error('Test stage finished: FAILURE') |
| 328 | } |
| 329 | |
| 330 | } catch (Throwable e) { |
| 331 | currentBuild.result = "FAILURE" |
| 332 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 333 | throw e |
| 334 | } finally { |
| 335 | stage('Clean workspace directories') { |
| 336 | sh(script: 'find . -mindepth 1 -delete > /dev/null || true') |
| 337 | } |
| 338 | // common.sendNotification(currentBuild.result,"",["slack"]) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 339 | } |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 340 | } |
Mikhail Ivanov | 9f81292 | 2017-11-07 18:52:02 +0400 | [diff] [blame] | 341 | } |