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