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 | * |
| 8 | **/ |
| 9 | |
Leontii Istomin | 9adf918 | 2018-02-23 13:16:20 +0100 | [diff] [blame] | 10 | // Deprecation to avoid unexpected behaviour because it should be passed via initial context. |
| 11 | // Need to delete this "if" statement at 1 April 2018. |
| 12 | if(env.COOKIECUTTER_TEMPLATE_CREDENTIALS || |
| 13 | env.COOKIECUTTER_TEMPLATE_URL || |
| 14 | env.COOKIECUTTER_TEMPLATE_BRANCH || |
| 15 | env.COOKIECUTTER_TEMPLATE_PATH || |
| 16 | env.SHARED_RECLASS_URL){ |
| 17 | println ''' |
| 18 | DEPRECATION: Please note that the following variables are deprocated: |
| 19 | - COOKIECUTTER_TEMPLATE_CREDENTIALS |
| 20 | - COOKIECUTTER_TEMPLATE_URL |
| 21 | - COOKIECUTTER_TEMPLATE_BRANCH |
| 22 | - COOKIECUTTER_TEMPLATE_PATH |
| 23 | - SHARED_RECLASS_URL |
| 24 | You need to pass the values using the following variables from initial cookiecutter context: |
| 25 | - cookiecutter_template_url |
| 26 | - cookiecutter_template_branch |
| 27 | - shared_reclass_url |
| 28 | The following variables are not needed anymore: |
| 29 | - COOKIECUTTER_TEMPLATE_CREDENTIALS - cookiecutter-templates repos are accessible for anounimous |
| 30 | (https://gerrit.mcp.mirantis.net) |
| 31 | - COOKIECUTTER_TEMPLATE_PATH - hardcoded to "${env.WORKSPACE}/template" |
| 32 | ''' |
| 33 | currentBuild.result = "FAILURE" |
| 34 | return |
| 35 | } |
| 36 | |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 37 | common = new com.mirantis.mk.Common() |
| 38 | git = new com.mirantis.mk.Git() |
| 39 | python = new com.mirantis.mk.Python() |
chnyda | 8919101 | 2017-05-29 15:38:35 +0200 | [diff] [blame] | 40 | saltModelTesting = new com.mirantis.mk.SaltModelTesting() |
Tomáš Kukrál | cebc1a0 | 2017-07-25 16:10:37 +0200 | [diff] [blame] | 41 | ssh = new com.mirantis.mk.Ssh() |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 42 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 43 | timeout(time: 12, unit: 'HOURS') { |
| 44 | node("python&&docker") { |
| 45 | def templateEnv = "${env.WORKSPACE}/template" |
| 46 | def modelEnv = "${env.WORKSPACE}/model" |
| 47 | def testEnv = "${env.WORKSPACE}/test" |
| 48 | def pipelineEnv = "${env.WORKSPACE}/pipelines" |
Tomáš Kukrál | 9f6260f | 2017-03-29 23:58:26 +0200 | [diff] [blame] | 49 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 50 | try { |
| 51 | def templateContext = readYaml text: COOKIECUTTER_TEMPLATE_CONTEXT |
Leontii Istomin | 9adf918 | 2018-02-23 13:16:20 +0100 | [diff] [blame] | 52 | def mcpVersion = templateContext.default_context.mcp_version |
| 53 | def sharedReclassUrl = templateContext.default_context.shared_reclass_url |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 54 | def clusterDomain = templateContext.default_context.cluster_domain |
| 55 | def clusterName = templateContext.default_context.cluster_name |
| 56 | def saltMaster = templateContext.default_context.salt_master_hostname |
Richard Felkl | e77b091 | 2018-01-31 17:12:23 +0100 | [diff] [blame] | 57 | def localRepositories = templateContext.default_context.local_repositories.toBoolean() |
| 58 | def offlineDeployment = templateContext.default_context.offline_deployment.toBoolean() |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 59 | def cutterEnv = "${env.WORKSPACE}/cutter" |
| 60 | def jinjaEnv = "${env.WORKSPACE}/jinja" |
| 61 | def outputDestination = "${modelEnv}/classes/cluster/${clusterName}" |
Leontii Istomin | 9adf918 | 2018-02-23 13:16:20 +0100 | [diff] [blame] | 62 | def systemEnv = "${modelEnv}/classes/system" |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 63 | def targetBranch = "feature/${clusterName}" |
| 64 | def templateBaseDir = "${env.WORKSPACE}/template" |
| 65 | def templateDir = "${templateEnv}/template/dir" |
| 66 | def templateOutputDir = templateBaseDir |
| 67 | def user |
| 68 | wrap([$class: 'BuildUser']) { |
| 69 | user = env.BUILD_USER_ID |
Tomáš Kukrál | a3f4ba7 | 2017-08-03 15:40:22 +0200 | [diff] [blame] | 70 | } |
| 71 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 72 | currentBuild.description = clusterName |
| 73 | print("Using context:\n" + COOKIECUTTER_TEMPLATE_CONTEXT) |
Tomáš Kukrál | 0c6835d | 2017-07-18 16:00:27 +0200 | [diff] [blame] | 74 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 75 | stage ('Download Cookiecutter template') { |
Leontii Istomin | 9adf918 | 2018-02-23 13:16:20 +0100 | [diff] [blame] | 76 | def cookiecutterTemplateUrl = templateContext.default_context.cookiecutter_template_url |
| 77 | def cookiecutterTemplateBranch = templateContext.default_context.cookiecutter_template_branch |
| 78 | git.checkoutGitRepository(templateEnv, cookiecutterTemplateUrl, 'master') |
| 79 | // Use refspec if exists first of all |
| 80 | if (cookiecutterTemplateBranch.toString().startsWith('refs/')) { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 81 | dir(templateEnv) { |
Leontii Istomin | 9adf918 | 2018-02-23 13:16:20 +0100 | [diff] [blame] | 82 | ssh.agentSh("git fetch ${cookiecutterTemplateUrl} ${cookiecutterTemplateBranch} && git checkout FETCH_HEAD") |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 83 | } |
| 84 | } else { |
Leontii Istomin | 9adf918 | 2018-02-23 13:16:20 +0100 | [diff] [blame] | 85 | // Use mcpVersion git tag if not specified branch for cookiecutter-templates |
| 86 | if (cookiecutterTemplateBranch == '') { |
| 87 | cookiecutterTemplateBranch = mcpVersion |
| 88 | // Don't have nightly/testing/stable for cookiecutter-templates repo, therefore use master |
| 89 | if(mcpVersion == "nightly" || mcpVersion == "testing" || mcpVersion == "stable"){ |
| 90 | cookiecutterTemplateBranch = 'master' |
| 91 | } |
| 92 | } |
| 93 | git.changeGitBranch(templateEnv, cookiecutterTemplateBranch) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 94 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | stage ('Create empty reclass model') { |
| 98 | dir(path: modelEnv) { |
| 99 | sh "rm -rfv .git" |
| 100 | sh "git init" |
Leontii Istomin | 4bf8bc7 | 2018-03-02 10:36:39 +0100 | [diff] [blame] | 101 | ssh.agentSh("git submodule add ${sharedReclassUrl} 'classes/system'") |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 102 | } |
Richard Felkl | e77b091 | 2018-01-31 17:12:23 +0100 | [diff] [blame] | 103 | |
Leontii Istomin | 9adf918 | 2018-02-23 13:16:20 +0100 | [diff] [blame] | 104 | def sharedReclassBranch = templateContext.default_context.shared_reclass_branch |
| 105 | // Use refspec if exists first of all |
| 106 | if (sharedReclassBranch.toString().startsWith('refs/')) { |
| 107 | dir(systemEnv) { |
| 108 | ssh.agentSh("git fetch ${sharedReclassUrl} ${sharedReclassBranch} && git checkout FETCH_HEAD") |
| 109 | } |
| 110 | } else { |
| 111 | // Use mcpVersion git tag if not specified branch for reclass-system |
| 112 | if (sharedReclassBranch == '') { |
| 113 | sharedReclassBranch = mcpVersion |
| 114 | // Don't have nightly/testing/stable for reclass-system repo, therefore use master |
| 115 | if(mcpVersion == "nightly" || mcpVersion == "testing" || mcpVersion == "stable"){ |
| 116 | sharedReclassBranch = 'master' |
| 117 | } |
| 118 | } |
| 119 | git.changeGitBranch(systemEnv, sharedReclassBranch) |
| 120 | } |
| 121 | git.commitGitChanges(modelEnv, "Added new shared reclass submodule", "${user}@localhost", "${user}") |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | def productList = ["infra", "cicd", "opencontrail", "kubernetes", "openstack", "oss", "stacklight", "ceph"] |
| 125 | for (product in productList) { |
| 126 | |
| 127 | // get templateOutputDir and productDir |
| 128 | if (product.startsWith("stacklight")) { |
| 129 | templateOutputDir = "${env.WORKSPACE}/output/stacklight" |
| 130 | |
| 131 | def stacklightVersion |
| 132 | try { |
| 133 | stacklightVersion = templateContext.default_context['stacklight_version'] |
| 134 | } catch (Throwable e) { |
| 135 | common.warningMsg('Stacklight version loading failed') |
Richard Felkl | 9543faa | 2018-01-11 09:47:35 +0100 | [diff] [blame] | 136 | } |
| 137 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 138 | if (stacklightVersion) { |
| 139 | productDir = "stacklight" + stacklightVersion |
| 140 | } else { |
| 141 | productDir = "stacklight1" |
| 142 | } |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 143 | |
Tomáš Kukrál | a3f4ba7 | 2017-08-03 15:40:22 +0200 | [diff] [blame] | 144 | } else { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 145 | templateOutputDir = "${env.WORKSPACE}/output/${product}" |
| 146 | productDir = product |
Tomáš Kukrál | 9a6821e | 2017-07-24 11:07:01 +0200 | [diff] [blame] | 147 | } |
Tomáš Kukrál | a3f4ba7 | 2017-08-03 15:40:22 +0200 | [diff] [blame] | 148 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 149 | if (product == "infra" || (templateContext.default_context["${product}_enabled"] |
| 150 | && templateContext.default_context["${product}_enabled"].toBoolean())) { |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 151 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 152 | templateDir = "${templateEnv}/cluster_product/${productDir}" |
| 153 | common.infoMsg("Generating product " + product + " from " + templateDir + " to " + templateOutputDir) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 154 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 155 | sh "rm -rf ${templateOutputDir} || true" |
| 156 | sh "mkdir -p ${templateOutputDir}" |
| 157 | sh "mkdir -p ${outputDestination}" |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 158 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 159 | python.setupCookiecutterVirtualenv(cutterEnv) |
| 160 | python.buildCookiecutterTemplate(templateDir, COOKIECUTTER_TEMPLATE_CONTEXT, templateOutputDir, cutterEnv, templateBaseDir) |
| 161 | sh "mv -v ${templateOutputDir}/${clusterName}/* ${outputDestination}" |
Jiri Broulik | d1375f7 | 2018-01-09 10:14:59 +0100 | [diff] [blame] | 162 | } else { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 163 | common.warningMsg("Product " + product + " is disabled") |
Jiri Broulik | d1375f7 | 2018-01-09 10:14:59 +0100 | [diff] [blame] | 164 | } |
| 165 | } |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 166 | |
Richard Felkl | e77b091 | 2018-01-31 17:12:23 +0100 | [diff] [blame] | 167 | if(localRepositories && !offlineDeployment){ |
| 168 | def aptlyModelUrl = templateContext.default_context.local_model_url |
| 169 | dir(path: modelEnv) { |
| 170 | ssh.agentSh "git submodule add \"${aptlyModelUrl}\" \"classes/cluster/${clusterName}/cicd/aptly\"" |
| 171 | if(!(mcpVersion in ["nightly", "testing", "stable"])){ |
| 172 | ssh.agentSh "cd \"classes/cluster/${clusterName}/cicd/aptly\";git fetch --tags;git checkout ${mcpVersion}" |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 177 | stage('Generate new SaltMaster node') { |
| 178 | def nodeFile = "${modelEnv}/nodes/${saltMaster}.${clusterDomain}.yml" |
| 179 | def nodeString = """classes: |
Leontii Istomin | 56b6b11 | 2018-01-15 12:14:24 +0300 | [diff] [blame] | 180 | - cluster.${clusterName}.infra.config |
| 181 | parameters: |
| 182 | _param: |
| 183 | linux_system_codename: xenial |
| 184 | reclass_data_revision: master |
| 185 | linux: |
| 186 | system: |
| 187 | name: ${saltMaster} |
| 188 | domain: ${clusterDomain} |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 189 | """ |
| 190 | sh "mkdir -p ${modelEnv}/nodes/" |
| 191 | writeFile(file: nodeFile, text: nodeString) |
| 192 | |
| 193 | git.commitGitChanges(modelEnv, "Create model ${clusterName}", "${user}@localhost", "${user}") |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 194 | } |
| 195 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 196 | stage("Test") { |
Leontii Istomin | 9adf918 | 2018-02-23 13:16:20 +0100 | [diff] [blame] | 197 | if (sharedReclassUrl != "" && TEST_MODEL && TEST_MODEL.toBoolean()) { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 198 | sh("cp -r ${modelEnv} ${testEnv}") |
| 199 | saltModelTesting.setupAndTestNode("${saltMaster}.${clusterDomain}", "", testEnv) |
| 200 | } |
| 201 | } |
Richard Felkl | 9fd4794 | 2017-10-20 16:23:29 +0200 | [diff] [blame] | 202 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 203 | stage("Generate config drives") { |
| 204 | // apt package genisoimage is required for this stage |
Richard Felkl | 9fd4794 | 2017-10-20 16:23:29 +0200 | [diff] [blame] | 205 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 206 | // download create-config-drive |
| 207 | // FIXME: that should be refactored, to use git clone - to be able download it from custom repo. |
| 208 | def config_drive_script_url = "https://raw.githubusercontent.com/Mirantis/mcp-common-scripts/master/config-drive/create_config_drive.sh" |
| 209 | def user_data_script_url = "https://raw.githubusercontent.com/Mirantis/mcp-common-scripts/master/config-drive/master_config.sh" |
Richard Felkl | 9fd4794 | 2017-10-20 16:23:29 +0200 | [diff] [blame] | 210 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 211 | sh "wget -O create-config-drive ${config_drive_script_url} && chmod +x create-config-drive" |
| 212 | sh "wget -O user_data.sh ${user_data_script_url}" |
Richard Felkl | 9fd4794 | 2017-10-20 16:23:29 +0200 | [diff] [blame] | 213 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 214 | sh "git clone --mirror https://github.com/Mirantis/mk-pipelines.git ${pipelineEnv}/mk-pipelines" |
| 215 | sh "git clone --mirror https://github.com/Mirantis/pipeline-library.git ${pipelineEnv}/pipeline-library" |
| 216 | args = "--user-data user_data.sh --hostname ${saltMaster} --model ${modelEnv} --mk-pipelines ${pipelineEnv}/mk-pipelines/ --pipeline-library ${pipelineEnv}/pipeline-library/ ${saltMaster}.${clusterDomain}-config.iso" |
| 217 | |
| 218 | // load data from model |
| 219 | def smc = [:] |
| 220 | smc['SALT_MASTER_MINION_ID'] = "${saltMaster}.${clusterDomain}" |
| 221 | smc['SALT_MASTER_DEPLOY_IP'] = templateContext['default_context']['salt_master_management_address'] |
| 222 | smc['DEPLOY_NETWORK_GW'] = templateContext['default_context']['deploy_network_gateway'] |
| 223 | smc['DEPLOY_NETWORK_NETMASK'] = templateContext['default_context']['deploy_network_netmask'] |
| 224 | smc['DNS_SERVERS'] = templateContext['default_context']['dns_server01'] |
| 225 | if (templateContext['default_context']['local_repositories'] == 'True'){ |
| 226 | smc['PIPELINES_FROM_ISO'] = 'false' |
| 227 | smc['PIPELINE_REPO_URL'] = 'http://' + templateContext['default_context']['aptly_server_deploy_address'] + ':8088' |
| 228 | } |
| 229 | if (templateContext['default_context']['upstream_proxy_enabled'] == 'True'){ |
| 230 | if (templateContext['default_context']['upstream_proxy_auth_enabled'] == 'True'){ |
| 231 | 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'] |
| 232 | 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'] |
| 233 | } else { |
| 234 | smc['http_proxy'] = 'http://' + templateContext['default_context']['upstream_proxy_address'] + ':' + templateContext['default_context']['upstream_proxy_port'] |
| 235 | smc['https_proxy'] = 'http://' + templateContext['default_context']['upstream_proxy_address'] + ':' + templateContext['default_context']['upstream_proxy_port'] |
| 236 | } |
Richard Felkl | 9fd4794 | 2017-10-20 16:23:29 +0200 | [diff] [blame] | 237 | } |
| 238 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 239 | for (i in common.entries(smc)) { |
| 240 | sh "sed -i \"s,export ${i[0]}=.*,export ${i[0]}=${i[1]},\" user_data.sh" |
| 241 | } |
Richard Felkl | 9fd4794 | 2017-10-20 16:23:29 +0200 | [diff] [blame] | 242 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 243 | // create cfg config-drive |
| 244 | sh "./create-config-drive ${args}" |
| 245 | sh("mkdir output-${clusterName} && mv ${saltMaster}.${clusterDomain}-config.iso output-${clusterName}/") |
| 246 | |
| 247 | // save cfg iso to artifacts |
| 248 | archiveArtifacts artifacts: "output-${clusterName}/${saltMaster}.${clusterDomain}-config.iso" |
| 249 | |
| 250 | if (templateContext['default_context']['local_repositories'] == 'True'){ |
| 251 | def aptlyServerHostname = templateContext.default_context.aptly_server_hostname |
| 252 | def user_data_script_apt_url = "https://raw.githubusercontent.com/Mirantis/mcp-common-scripts/master/config-drive/mirror_config.sh" |
| 253 | sh "wget -O mirror_config.sh ${user_data_script_apt_url}" |
| 254 | |
| 255 | def smc_apt = [:] |
| 256 | smc_apt['SALT_MASTER_DEPLOY_IP'] = templateContext['default_context']['salt_master_management_address'] |
| 257 | smc_apt['APTLY_DEPLOY_IP'] = templateContext['default_context']['aptly_server_deploy_address'] |
| 258 | smc_apt['APTLY_DEPLOY_NETMASK'] = templateContext['default_context']['deploy_network_netmask'] |
| 259 | smc_apt['APTLY_MINION_ID'] = "${aptlyServerHostname}.${clusterDomain}" |
| 260 | |
| 261 | for (i in common.entries(smc_apt)) { |
| 262 | sh "sed -i \"s,export ${i[0]}=.*,export ${i[0]}=${i[1]},\" mirror_config.sh" |
| 263 | } |
| 264 | |
| 265 | // create apt config-drive |
| 266 | sh "./create-config-drive --user-data mirror_config.sh --hostname ${aptlyServerHostname} ${aptlyServerHostname}.${clusterDomain}-config.iso" |
| 267 | sh("mv ${aptlyServerHostname}.${clusterDomain}-config.iso output-${clusterName}/") |
| 268 | |
| 269 | // save apt iso to artifacts |
| 270 | archiveArtifacts artifacts: "output-${clusterName}/${aptlyServerHostname}.${clusterDomain}-config.iso" |
| 271 | } |
Richard Felkl | 9fd4794 | 2017-10-20 16:23:29 +0200 | [diff] [blame] | 272 | } |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 273 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 274 | stage ('Save changes reclass model') { |
| 275 | sh(returnStatus: true, script: "tar -zcf output-${clusterName}/${clusterName}.tar.gz -C ${modelEnv} .") |
| 276 | archiveArtifacts artifacts: "output-${clusterName}/${clusterName}.tar.gz" |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 277 | |
| 278 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 279 | if (EMAIL_ADDRESS != null && EMAIL_ADDRESS != "") { |
| 280 | emailext(to: EMAIL_ADDRESS, |
| 281 | attachmentsPattern: "output-${clusterName}/*", |
| 282 | body: "Mirantis Jenkins\n\nRequested reclass model ${clusterName} has been created and attached to this email.\nEnjoy!\n\nMirantis", |
| 283 | subject: "Your Salt model ${clusterName}") |
| 284 | } |
| 285 | dir("output-${clusterName}"){ |
| 286 | deleteDir() |
| 287 | } |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 288 | } |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 289 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 290 | } catch (Throwable e) { |
| 291 | // If there was an error or exception thrown, the build failed |
| 292 | currentBuild.result = "FAILURE" |
| 293 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 294 | throw e |
| 295 | } finally { |
| 296 | stage ('Clean workspace directories') { |
| 297 | sh(returnStatus: true, script: "rm -rf ${templateEnv}") |
| 298 | sh(returnStatus: true, script: "rm -rf ${modelEnv}") |
| 299 | sh(returnStatus: true, script: "rm -rf ${pipelineEnv}") |
| 300 | } |
| 301 | // common.sendNotification(currentBuild.result,"",["slack"]) |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 302 | } |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 303 | } |
Mikhail Ivanov | 9f81292 | 2017-11-07 18:52:02 +0400 | [diff] [blame] | 304 | } |