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 |
Denis Egorenko | 032a2b7 | 2019-04-03 14:56:52 +0400 | [diff] [blame] | 11 | import org.apache.commons.net.util.SubnetUtils |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 12 | |
| 13 | common = new com.mirantis.mk.Common() |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 14 | common2 = new com.mirantis.mcp.Common() |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 15 | git = new com.mirantis.mk.Git() |
| 16 | python = new com.mirantis.mk.Python() |
chnyda | 8919101 | 2017-05-29 15:38:35 +0200 | [diff] [blame] | 17 | saltModelTesting = new com.mirantis.mk.SaltModelTesting() |
azvyagintsev | 5b7ec89 | 2019-05-15 16:37:34 +0300 | [diff] [blame] | 18 | updateSaltFormulasDuringTest = true |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 19 | |
Aleksey Zvyagintsev | 4a80421 | 2019-02-07 13:02:31 +0000 | [diff] [blame] | 20 | slaveNode = env.getProperty('SLAVE_NODE') ?: 'virtual' |
azvyagintsev | 6d678da | 2018-11-28 21:19:06 +0200 | [diff] [blame] | 21 | gerritCredentials = env.getProperty('CREDENTIALS_ID') ?: 'gerrit' |
| 22 | runTestModel = (env.getProperty('TEST_MODEL') ?: true).toBoolean() |
Hanna Arhipova | 5132ed4 | 2021-09-08 12:30:37 +0300 | [diff] [blame] | 23 | saveToArtifactory = (env.getProperty('SAVE_TO_ARTIFACTORY') ?: true).toBoolean() |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 24 | distribRevision = 'proposed' |
| 25 | gitGuessedVersion = false |
Ivan Berezovskiy | f590bc6 | 2020-02-28 17:29:17 +0400 | [diff] [blame] | 26 | aptlyServerHostname = '' |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 27 | |
Denis Egorenko | ce93af3 | 2019-05-20 16:57:33 +0400 | [diff] [blame] | 28 | def GenerateModelToxDocker(Map params) { |
| 29 | def ccRoot = params['ccRoot'] |
| 30 | def context = params['context'] |
| 31 | def outDir = params['outDir'] |
| 32 | def envOpts = params['envOpts'] |
| 33 | def tempContextFile = new File(ccRoot, 'tempContext.yaml_' + UUID.randomUUID().toString()).toString() |
| 34 | writeFile file: tempContextFile, text: context |
| 35 | // Get Jenkins user UID and GID |
| 36 | def jenkinsUID = sh(script: 'id -u', returnStdout: true).trim() |
| 37 | def jenkinsGID = sh(script: 'id -g', returnStdout: true).trim() |
| 38 | /* |
| 39 | by default, process in image operates via root user |
| 40 | Otherwise, gpg key for model and all files managed by jenkins user |
| 41 | To make it compatible, install rrequirementfrom user, but generate model via jenkins |
| 42 | for build use upstream Ubuntu Bionic image |
| 43 | */ |
| 44 | def configRun = ['distribRevision': 'nightly', |
| 45 | 'envOpts' : envOpts + ["CONFIG_FILE=$tempContextFile", |
| 46 | "OUTPUT_DIR=${outDir}" |
| 47 | ], |
Aleksey Zvyagintsev | 1cbd4d7 | 2019-05-24 14:08:19 +0000 | [diff] [blame] | 48 | 'image': 'docker-prod-local.artifactory.mirantis.com/mirantis/cicd/jnlp-slave', |
Denis Egorenko | ce93af3 | 2019-05-20 16:57:33 +0400 | [diff] [blame] | 49 | 'runCommands' : [ |
| 50 | '001_prepare_generate_auto_reqs': { |
Aleksey Zvyagintsev | 1cbd4d7 | 2019-05-24 14:08:19 +0000 | [diff] [blame] | 51 | sh(''' |
Denis Egorenko | ce93af3 | 2019-05-20 16:57:33 +0400 | [diff] [blame] | 52 | pip install tox |
| 53 | ''') |
| 54 | }, |
| 55 | // user & group can be different on host and in docker |
Aleksey Zvyagintsev | 1cbd4d7 | 2019-05-24 14:08:19 +0000 | [diff] [blame] | 56 | '002_set_jenkins_id': { |
| 57 | sh(""" |
Denis Egorenko | ce93af3 | 2019-05-20 16:57:33 +0400 | [diff] [blame] | 58 | usermod -u ${jenkinsUID} jenkins |
Ivan Berezovskiy | 6c6118a | 2019-12-10 17:21:46 +0400 | [diff] [blame] | 59 | groupmod -g ${jenkinsGID} jenkins |
Denis Egorenko | ce93af3 | 2019-05-20 16:57:33 +0400 | [diff] [blame] | 60 | """) |
| 61 | }, |
Aleksey Zvyagintsev | 1cbd4d7 | 2019-05-24 14:08:19 +0000 | [diff] [blame] | 62 | '003_run_generate_auto': { |
Denis Egorenko | ce93af3 | 2019-05-20 16:57:33 +0400 | [diff] [blame] | 63 | print('[Cookiecutter build] Result:\n' + |
| 64 | sh(returnStdout: true, script: 'cd ' + ccRoot + '; su jenkins -c "tox -ve generate_auto" ')) |
| 65 | } |
| 66 | ] |
| 67 | ] |
| 68 | |
| 69 | saltModelTesting.setupDockerAndTest(configRun) |
| 70 | } |
| 71 | |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 72 | def globalVariatorsUpdate() { |
| 73 | def templateContext = readYaml text: env.COOKIECUTTER_TEMPLATE_CONTEXT |
| 74 | def context = templateContext['default_context'] |
| 75 | // TODO add more check's for critical var's |
| 76 | // Since we can't pin to any '_branch' variable from context, to identify 'default git revision' - |
| 77 | // because each of them, might be 'refs/' variable, we need to add some tricky trigger of using |
| 78 | // 'release/XXX' logic. This is totall guess - so,if even those one failed, to definitely must pass |
| 79 | // correct variable finally! |
Denis Egorenko | f0d213d | 2019-06-03 19:05:40 +0400 | [diff] [blame] | 80 | [ context.get('cookiecutter_template_branch'), context.get('shared_reclass_branch'), context.get('mcp_common_scripts_branch') ].any { branch -> |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 81 | if (branch.toString().startsWith('release/')) { |
| 82 | gitGuessedVersion = branch |
| 83 | return true |
| 84 | } |
| 85 | } |
Denis Egorenko | f0d213d | 2019-06-03 19:05:40 +0400 | [diff] [blame] | 86 | |
| 87 | [ 'cookiecutter_template_branch', 'shared_reclass_branch', 'mcp_common_scripts_branch' ].each { repoName -> |
Denis Egorenko | 0b28390 | 2019-06-04 13:09:15 +0400 | [diff] [blame] | 88 | if (context['mcp_version'] in [ "nightly", "testing", "stable" ] && ! context.get(repoName)) { |
Denis Egorenko | f0d213d | 2019-06-03 19:05:40 +0400 | [diff] [blame] | 89 | context[repoName] = 'master' |
| 90 | } else if (! context.get(repoName)) { |
| 91 | context[repoName] = gitGuessedVersion ?: "release/${context['mcp_version']}".toString() |
| 92 | } |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 93 | } |
| 94 | // |
| 95 | distribRevision = context['mcp_version'] |
| 96 | if (['master'].contains(context['mcp_version'])) { |
| 97 | distribRevision = 'nightly' |
| 98 | } |
| 99 | if (distribRevision.contains('/')) { |
| 100 | distribRevision = distribRevision.split('/')[-1] |
| 101 | } |
| 102 | // 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] | 103 | // After 2018q4 releases, need to also check 'static' repo, for example ubuntu. |
azvyagintsev | 4f34f7a | 2019-02-26 18:47:37 +0200 | [diff] [blame] | 104 | def binTest = common.checkRemoteBinary(['mcp_version': distribRevision]) |
azvyagintsev | 8e08164 | 2019-02-03 19:15:22 +0200 | [diff] [blame] | 105 | if (!binTest.linux_system_repo_url || !binTest.linux_system_repo_ubuntu_url) { |
| 106 | common.errorMsg("Binary release: ${distribRevision} not exist or not full. Fallback to 'proposed'! ") |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 107 | distribRevision = 'proposed' |
| 108 | } |
azvyagintsev | 8e08164 | 2019-02-03 19:15:22 +0200 | [diff] [blame] | 109 | |
azvyagintsev | 5400d1d | 2018-12-11 13:19:29 +0200 | [diff] [blame] | 110 | // (azvyagintsev) WA for PROD-25732 |
| 111 | if (context.cookiecutter_template_url.contains('gerrit.mcp.mirantis.com/mk/cookiecutter-templates')) { |
| 112 | common.warningMsg('Apply WA for PROD-25732') |
| 113 | context.cookiecutter_template_url = 'ssh://gerrit.mcp.mirantis.com:29418/mk/cookiecutter-templates.git' |
| 114 | } |
Ivan Berezovskiy | 6c6118a | 2019-12-10 17:21:46 +0400 | [diff] [blame] | 115 | // check, if we are going to test clear release version, w\o any updates and patches. |
| 116 | // All 2019.2.X starting from 2019.2.1 and above have update repo which has to be used for salt-formulas. |
| 117 | // update/2019.2.0 repo can't be used b/c it points to latest 2019.2.X |
| 118 | if (!gitGuessedVersion && (distribRevision == context.mcp_version) && !(distribRevision ==~ /2019\.2\.[1-9]\d*/)) { |
azvyagintsev | 5b7ec89 | 2019-05-15 16:37:34 +0300 | [diff] [blame] | 119 | updateSaltFormulasDuringTest = false |
| 120 | } |
| 121 | |
Ivan Berezovskiy | 1e66f50 | 2019-05-24 18:11:17 +0400 | [diff] [blame] | 122 | if (gitGuessedVersion == 'release/proposed/2019.2.0') { |
Denis Egorenko | 83dfe21 | 2019-09-11 16:19:01 +0400 | [diff] [blame] | 123 | def mcpSaltRepoUpdateVar = 'deb [arch=amd64] http://mirror.mirantis.com/update/proposed/salt-formulas/xenial xenial main' |
| 124 | if (context.get('offline_deployment', 'False').toBoolean()) { |
Denis Egorenko | a43c66e | 2019-09-11 16:40:56 +0400 | [diff] [blame] | 125 | mcpSaltRepoUpdateVar = "deb [arch=amd64] http://${context.get('aptly_server_deploy_address')}/update/proposed/salt-formulas/xenial xenial main".toString() |
Denis Egorenko | 83dfe21 | 2019-09-11 16:19:01 +0400 | [diff] [blame] | 126 | } |
Ivan Berezovskiy | 1e66f50 | 2019-05-24 18:11:17 +0400 | [diff] [blame] | 127 | // CFG node in 2019.2.X update has to be bootstrapped with update/proposed repository for salt formulas |
| 128 | context['cloudinit_master_config'] = context.get('cloudinit_master_config', false) ?: [:] |
Denis Egorenko | 83dfe21 | 2019-09-11 16:19:01 +0400 | [diff] [blame] | 129 | context['cloudinit_master_config']['MCP_SALT_REPO_UPDATES'] = context['cloudinit_master_config'].get('MCP_SALT_REPO_UPDATES', false) ?: mcpSaltRepoUpdateVar |
Ivan Berezovskiy | 1e66f50 | 2019-05-24 18:11:17 +0400 | [diff] [blame] | 130 | } |
| 131 | |
Denis Egorenko | c1e1d04 | 2019-04-26 08:55:27 +0000 | [diff] [blame] | 132 | common.infoMsg("Using context:\n" + context) |
Aleksey Zvyagintsev | 7ca28d2 | 2019-02-25 11:05:49 +0000 | [diff] [blame] | 133 | print prettyPrint(toJson(context)) |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 134 | return context |
| 135 | |
| 136 | } |
azvyagintsev | f252b59 | 2018-08-13 18:39:14 +0300 | [diff] [blame] | 137 | |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 138 | timeout(time: 1, unit: 'HOURS') { |
Aleksey Zvyagintsev | 7ca28d2 | 2019-02-25 11:05:49 +0000 | [diff] [blame] | 139 | node(slaveNode) { |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 140 | def context = globalVariatorsUpdate() |
azvyagintsev | 6d678da | 2018-11-28 21:19:06 +0200 | [diff] [blame] | 141 | def RequesterEmail = context.get('email_address', '') |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 142 | def templateEnv = "${env.WORKSPACE}/template" |
azvyagintsev | 4f34f7a | 2019-02-26 18:47:37 +0200 | [diff] [blame] | 143 | // modelEnv - this is reclass root, aka /srv/salt/reclass |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 144 | def modelEnv = "${env.WORKSPACE}/model" |
| 145 | def testEnv = "${env.WORKSPACE}/test" |
| 146 | def pipelineEnv = "${env.WORKSPACE}/pipelines" |
Tomáš Kukrál | 9f6260f | 2017-03-29 23:58:26 +0200 | [diff] [blame] | 147 | |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 148 | try { |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 149 | // |
| 150 | def cutterEnv = "${env.WORKSPACE}/cutter" |
| 151 | def systemEnv = "${modelEnv}/classes/system" |
| 152 | def testResult = false |
| 153 | def user |
| 154 | wrap([$class: 'BuildUser']) { |
| 155 | user = env.BUILD_USER_ID |
| 156 | } |
azvyagintsev | 6d678da | 2018-11-28 21:19:06 +0200 | [diff] [blame] | 157 | currentBuild.description = "${context['cluster_name']} ${RequesterEmail}" |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 158 | |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 159 | stage('Download Cookiecutter template') { |
| 160 | sh(script: 'find . -mindepth 1 -delete > /dev/null || true') |
| 161 | checkout([ |
| 162 | $class : 'GitSCM', |
| 163 | branches : [[name: 'FETCH_HEAD'],], |
| 164 | extensions : [[$class: 'RelativeTargetDirectory', relativeTargetDir: templateEnv]], |
| 165 | userRemoteConfigs: [[url: context['cookiecutter_template_url'], refspec: context['cookiecutter_template_branch'], credentialsId: gerritCredentials],], |
| 166 | ]) |
| 167 | } |
| 168 | stage('Create empty reclass model') { |
| 169 | dir(path: modelEnv) { |
azvyagintsev | 4f34f7a | 2019-02-26 18:47:37 +0200 | [diff] [blame] | 170 | sh 'rm -rfv .git; git init' |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 171 | sshagent(credentials: [gerritCredentials]) { |
| 172 | sh "git submodule add ${context['shared_reclass_url']} 'classes/system'" |
| 173 | } |
| 174 | } |
| 175 | checkout([ |
| 176 | $class : 'GitSCM', |
| 177 | branches : [[name: 'FETCH_HEAD'],], |
| 178 | extensions : [[$class: 'RelativeTargetDirectory', relativeTargetDir: systemEnv]], |
| 179 | userRemoteConfigs: [[url: context['shared_reclass_url'], refspec: context['shared_reclass_branch'], credentialsId: gerritCredentials],], |
| 180 | ]) |
azvyagintsev | 4f34f7a | 2019-02-26 18:47:37 +0200 | [diff] [blame] | 181 | git.commitGitChanges(modelEnv, 'Added new shared reclass submodule', "${user}@localhost", "${user}") |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | stage('Generate model') { |
Denis Egorenko | c1e1d04 | 2019-04-26 08:55:27 +0000 | [diff] [blame] | 185 | // GNUPGHOME environment variable is required for all gpg commands |
| 186 | // and for python.generateModel execution |
Denis Egorenko | ce93af3 | 2019-05-20 16:57:33 +0400 | [diff] [blame] | 187 | def envOpts = ["GNUPGHOME=${env.WORKSPACE}/gpghome"] |
| 188 | withEnv(envOpts) { |
Dmitry Pyzhov | 089fb4f | 2018-12-11 16:58:00 +0300 | [diff] [blame] | 189 | if (context['secrets_encryption_enabled'] == 'True') { |
Denis Egorenko | c1e1d04 | 2019-04-26 08:55:27 +0000 | [diff] [blame] | 190 | sh "mkdir gpghome; chmod 700 gpghome" |
Dmitry Pyzhov | b5c74c7 | 2018-12-17 22:08:50 +0300 | [diff] [blame] | 191 | def secretKeyID = RequesterEmail ?: "salt@${context['cluster_domain']}".toString() |
Dmitry Pyzhov | 089fb4f | 2018-12-11 16:58:00 +0300 | [diff] [blame] | 192 | if (!context.get('secrets_encryption_private_key')) { |
| 193 | def batchData = """ |
Denis Egorenko | 131de5f | 2019-05-16 14:25:40 +0400 | [diff] [blame] | 194 | %echo Generating a basic OpenPGP key for Salt-Master |
| 195 | %no-protection |
Dmitry Pyzhov | 089fb4f | 2018-12-11 16:58:00 +0300 | [diff] [blame] | 196 | Key-Type: 1 |
| 197 | Key-Length: 4096 |
| 198 | Expire-Date: 0 |
| 199 | Name-Real: ${context['salt_master_hostname']}.${context['cluster_domain']} |
| 200 | Name-Email: ${secretKeyID} |
Denis Egorenko | 131de5f | 2019-05-16 14:25:40 +0400 | [diff] [blame] | 201 | %commit |
| 202 | %echo done |
Dmitry Pyzhov | 089fb4f | 2018-12-11 16:58:00 +0300 | [diff] [blame] | 203 | """.stripIndent() |
azvyagintsev | 7d6d46c | 2019-02-11 14:25:41 +0200 | [diff] [blame] | 204 | writeFile file: 'gpg-batch.txt', text: batchData |
Dmitry Pyzhov | 089fb4f | 2018-12-11 16:58:00 +0300 | [diff] [blame] | 205 | sh "gpg --gen-key --batch < gpg-batch.txt" |
| 206 | sh "gpg --export-secret-key -a ${secretKeyID} > gpgkey.asc" |
| 207 | } else { |
azvyagintsev | 7d6d46c | 2019-02-11 14:25:41 +0200 | [diff] [blame] | 208 | writeFile file: 'gpgkey.asc', text: context['secrets_encryption_private_key'] |
Vladimir Khlyunev | 9007296 | 2021-01-25 19:19:48 +0400 | [diff] [blame] | 209 | sh "gpg --batch --import gpgkey.asc" |
Denis Egorenko | 131de5f | 2019-05-16 14:25:40 +0400 | [diff] [blame] | 210 | secretKeyID = sh(returnStdout: true, script: 'gpg --list-secret-keys --with-colons | grep -E "^sec" | awk -F: \'{print \$5}\'').trim() |
Dmitry Pyzhov | 089fb4f | 2018-12-11 16:58:00 +0300 | [diff] [blame] | 211 | } |
| 212 | context['secrets_encryption_key_id'] = secretKeyID |
| 213 | } |
Stanislav Riazanov | da45ea0 | 2018-12-21 16:12:50 +0400 | [diff] [blame] | 214 | if (context.get('cfg_failsafe_ssh_public_key')) { |
azvyagintsev | 7d6d46c | 2019-02-11 14:25:41 +0200 | [diff] [blame] | 215 | writeFile file: 'failsafe-ssh-key.pub', text: context['cfg_failsafe_ssh_public_key'] |
Stanislav Riazanov | da45ea0 | 2018-12-21 16:12:50 +0400 | [diff] [blame] | 216 | } |
azvyagintsev | 4f34f7a | 2019-02-26 18:47:37 +0200 | [diff] [blame] | 217 | if (!fileExists(new File(templateEnv, 'tox.ini').toString())) { |
azvyagintsev | 06dfe40 | 2019-03-22 17:58:53 +0200 | [diff] [blame] | 218 | reqs = new File(templateEnv, 'requirements.txt').toString() |
| 219 | if (fileExists(reqs)) { |
| 220 | python.setupVirtualenv(cutterEnv, 'python2', [], reqs) |
| 221 | } else { |
| 222 | python.setupCookiecutterVirtualenv(cutterEnv) |
| 223 | } |
azvyagintsev | 4f34f7a | 2019-02-26 18:47:37 +0200 | [diff] [blame] | 224 | python.generateModel(common2.dumpYAML(['default_context': context]), 'default_context', context['salt_master_hostname'], cutterEnv, modelEnv, templateEnv, false) |
| 225 | } else { |
| 226 | // tox-based CC generated structure of reclass,from the root. Otherwise for bw compat, modelEnv |
| 227 | // still expect only lower lvl of project, aka model/classes/cluster/XXX/. So,lets dump result into |
| 228 | // temp dir, and then copy it over initial structure. |
| 229 | reclassTempRootDir = sh(script: "mktemp -d -p ${env.WORKSPACE}", returnStdout: true).trim() |
Denis Egorenko | ce93af3 | 2019-05-20 16:57:33 +0400 | [diff] [blame] | 230 | GenerateModelToxDocker(['context': common2.dumpYAML(['default_context': context]), |
| 231 | 'ccRoot' : templateEnv, |
| 232 | 'outDir' : reclassTempRootDir, |
| 233 | 'envOpts': envOpts]) |
azvyagintsev | 4f34f7a | 2019-02-26 18:47:37 +0200 | [diff] [blame] | 234 | dir(modelEnv) { |
| 235 | common.warningMsg('Forming reclass-root structure...') |
| 236 | sh("cp -ra ${reclassTempRootDir}/reclass/* .") |
| 237 | } |
| 238 | } |
Dmitry Pyzhov | 089fb4f | 2018-12-11 16:58:00 +0300 | [diff] [blame] | 239 | git.commitGitChanges(modelEnv, "Create model ${context['cluster_name']}", "${user}@localhost", "${user}") |
| 240 | } |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 241 | } |
| 242 | |
Denis Egorenko | c1e1d04 | 2019-04-26 08:55:27 +0000 | [diff] [blame] | 243 | stage("Test") { |
azvyagintsev | 6d678da | 2018-11-28 21:19:06 +0200 | [diff] [blame] | 244 | if (runTestModel) { |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 245 | sh("cp -r ${modelEnv} ${testEnv}") |
azvyagintsev | 7d6d46c | 2019-02-11 14:25:41 +0200 | [diff] [blame] | 246 | if (fileExists('gpgkey.asc')) { |
| 247 | common.infoMsg('gpgkey.asc found!Copy it into reclass folder for tests..') |
| 248 | sh("cp -v gpgkey.asc ${testEnv}/salt_master_pillar.asc") |
| 249 | } |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 250 | def DockerCName = "${env.JOB_NAME.toLowerCase()}_${env.BUILD_TAG.toLowerCase()}" |
azvyagintsev | 5b7ec89 | 2019-05-15 16:37:34 +0300 | [diff] [blame] | 251 | common.warningMsg("Attempt to run test against:\n" + |
| 252 | "DISTRIB_REVISION from ${distribRevision}\n" + |
| 253 | "updateSaltFormulasDuringTest = ${updateSaltFormulasDuringTest}") |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 254 | try { |
| 255 | def config = [ |
Denis Egorenko | 926bc7d | 2019-02-19 14:27:34 +0400 | [diff] [blame] | 256 | 'dockerHostname' : "${context['salt_master_hostname']}", |
| 257 | 'domain' : "${context['cluster_domain']}", |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 258 | 'reclassEnv' : testEnv, |
| 259 | 'distribRevision' : distribRevision, |
| 260 | 'dockerContainerName': DockerCName, |
Denis Egorenko | d87490e | 2019-02-26 20:00:41 +0400 | [diff] [blame] | 261 | 'testContext' : 'salt-model-node', |
azvyagintsev | 5b7ec89 | 2019-05-15 16:37:34 +0300 | [diff] [blame] | 262 | 'dockerExtraOpts' : ['--memory=3g'], |
| 263 | 'updateSaltFormulas' : updateSaltFormulasDuringTest |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 264 | ] |
Denis Egorenko | 19a793d | 2019-11-18 20:50:59 +0400 | [diff] [blame] | 265 | if (gitGuessedVersion == 'release/proposed/2019.2.0') { |
| 266 | config['updateSaltFormulasRev'] = 'proposed' |
| 267 | } |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 268 | testResult = saltModelTesting.testNode(config) |
| 269 | common.infoMsg("Test finished: SUCCESS") |
| 270 | } catch (Exception ex) { |
| 271 | common.warningMsg("Test finished: FAILED") |
| 272 | testResult = false |
| 273 | } |
| 274 | } else { |
| 275 | common.warningMsg("Test stage has been skipped!") |
| 276 | } |
| 277 | } |
| 278 | stage("Generate config drives") { |
| 279 | // apt package genisoimage is required for this stage |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 280 | // download create-config-drive |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 281 | def commonScriptsRepoUrl = context['mcp_common_scripts_repo'] ?: 'ssh://gerrit.mcp.mirantis.com:29418/mcp/mcp-common-scripts' |
| 282 | checkout([ |
| 283 | $class : 'GitSCM', |
| 284 | branches : [[name: 'FETCH_HEAD'],], |
| 285 | extensions : [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'mcp-common-scripts']], |
azvyagintsev | 866b19a | 2018-11-20 18:21:43 +0200 | [diff] [blame] | 286 | userRemoteConfigs: [[url: commonScriptsRepoUrl, refspec: context['mcp_common_scripts_branch'], credentialsId: gerritCredentials],], |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 287 | ]) |
| 288 | |
Denis Egorenko | aeaa013 | 2019-02-25 16:55:08 +0400 | [diff] [blame] | 289 | def outdateGeneration = false |
| 290 | if (fileExists('mcp-common-scripts/config-drive/create_config_drive.py')) { |
| 291 | sh 'cp mcp-common-scripts/config-drive/create_config_drive.py create-config-drive.py' |
| 292 | } else { |
| 293 | outdateGeneration = true |
| 294 | sh 'cp mcp-common-scripts/config-drive/create_config_drive.sh create-config-drive && chmod +x create-config-drive' |
| 295 | } |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 296 | 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' |
| 297 | |
Denis Egorenko | c1e1d04 | 2019-04-26 08:55:27 +0000 | [diff] [blame] | 298 | sh "git clone --mirror https://github.com/Mirantis/mk-pipelines.git ${pipelineEnv}/mk-pipelines" |
| 299 | sh "git clone --mirror https://github.com/Mirantis/pipeline-library.git ${pipelineEnv}/pipeline-library" |
Denis Egorenko | aeaa013 | 2019-02-25 16:55:08 +0400 | [diff] [blame] | 300 | args = [ |
azvyagintsev | 1385db9 | 2019-03-22 16:05:10 +0200 | [diff] [blame] | 301 | "--user-data user_data", "--model ${modelEnv}", |
Denis Egorenko | aeaa013 | 2019-02-25 16:55:08 +0400 | [diff] [blame] | 302 | "--mk-pipelines ${pipelineEnv}/mk-pipelines/", "--pipeline-library ${pipelineEnv}/pipeline-library/" |
| 303 | ] |
Dmitry Pyzhov | 089fb4f | 2018-12-11 16:58:00 +0300 | [diff] [blame] | 304 | if (context['secrets_encryption_enabled'] == 'True') { |
Denis Egorenko | aeaa013 | 2019-02-25 16:55:08 +0400 | [diff] [blame] | 305 | args.add('--gpg-key gpgkey.asc') |
Dmitry Pyzhov | 089fb4f | 2018-12-11 16:58:00 +0300 | [diff] [blame] | 306 | } |
Stanislav Riazanov | da45ea0 | 2018-12-21 16:12:50 +0400 | [diff] [blame] | 307 | if (context.get('cfg_failsafe_ssh_public_key')) { |
Denis Egorenko | aaeda9b | 2019-02-28 20:55:59 +0400 | [diff] [blame] | 308 | if (outdateGeneration) { |
| 309 | args.add('--ssh-key failsafe-ssh-key.pub') |
| 310 | } else { |
Denis Egorenko | 85ddf0d | 2019-03-18 18:11:19 +0400 | [diff] [blame] | 311 | if (context.get('cfg_failsafe_user')) { |
| 312 | args.add('--ssh-keys failsafe-ssh-key.pub') |
| 313 | args.add("--cloud-user-name ${context.get('cfg_failsafe_user')}") |
| 314 | } |
Denis Egorenko | aaeda9b | 2019-02-28 20:55:59 +0400 | [diff] [blame] | 315 | } |
Stanislav Riazanov | da45ea0 | 2018-12-21 16:12:50 +0400 | [diff] [blame] | 316 | } |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 317 | // load data from model |
| 318 | def smc = [:] |
| 319 | smc['SALT_MASTER_MINION_ID'] = "${context['salt_master_hostname']}.${context['cluster_domain']}" |
| 320 | smc['SALT_MASTER_DEPLOY_IP'] = context['salt_master_management_address'] |
Ivan Berezovskiy | 1e66f50 | 2019-05-24 18:11:17 +0400 | [diff] [blame] | 321 | if (context.get('cloudinit_master_config', false)) { |
| 322 | context['cloudinit_master_config'].each { k, v -> |
| 323 | smc[k] = v |
| 324 | } |
| 325 | } |
Denis Egorenko | aeaa013 | 2019-02-25 16:55:08 +0400 | [diff] [blame] | 326 | if (outdateGeneration) { |
| 327 | smc['DEPLOY_NETWORK_GW'] = context['deploy_network_gateway'] |
| 328 | smc['DEPLOY_NETWORK_NETMASK'] = context['deploy_network_netmask'] |
| 329 | if (context.get('deploy_network_mtu')) { |
| 330 | smc['DEPLOY_NETWORK_MTU'] = context['deploy_network_mtu'] |
| 331 | } |
| 332 | smc['DNS_SERVERS'] = context['dns_server01'] |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 333 | } |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 334 | smc['MCP_VERSION'] = "${context['mcp_version']}" |
| 335 | if (context['local_repositories'] == 'True') { |
Denis Egorenko | 6bfa755 | 2019-02-05 19:09:25 +0400 | [diff] [blame] | 336 | def localRepoIP = '' |
Denis Egorenko | f97aec2 | 2019-02-05 14:57:33 +0400 | [diff] [blame] | 337 | if (context['mcp_version'] in ['2018.4.0', '2018.8.0', '2018.8.0-milestone1', '2018.11.0']) { |
Denis Egorenko | 6bfa755 | 2019-02-05 19:09:25 +0400 | [diff] [blame] | 338 | localRepoIP = context['local_repo_url'] |
Denis Egorenko | f97aec2 | 2019-02-05 14:57:33 +0400 | [diff] [blame] | 339 | smc['MCP_SALT_REPO_URL'] = "http://${localRepoIP}/ubuntu-xenial" |
| 340 | } else { |
Denis Egorenko | 6bfa755 | 2019-02-05 19:09:25 +0400 | [diff] [blame] | 341 | localRepoIP = context['aptly_server_deploy_address'] |
Denis Egorenko | f97aec2 | 2019-02-05 14:57:33 +0400 | [diff] [blame] | 342 | smc['MCP_SALT_REPO_URL'] = "http://${localRepoIP}" |
| 343 | } |
Denis Egorenko | 6bfa755 | 2019-02-05 19:09:25 +0400 | [diff] [blame] | 344 | smc['MCP_SALT_REPO_KEY'] = "http://${localRepoIP}/public.gpg" |
Denis Egorenko | 5f1c0d9 | 2019-09-26 09:03:57 +0000 | [diff] [blame] | 345 | smc['PIPELINES_FROM_ISO'] = 'false' |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 346 | smc['PIPELINE_REPO_URL'] = "http://${localRepoIP}:8088" |
| 347 | smc['LOCAL_REPOS'] = 'true' |
| 348 | } |
| 349 | if (context['upstream_proxy_enabled'] == 'True') { |
| 350 | if (context['upstream_proxy_auth_enabled'] == 'True') { |
| 351 | smc['http_proxy'] = 'http://' + context['upstream_proxy_user'] + ':' + context['upstream_proxy_password'] + '@' + context['upstream_proxy_address'] + ':' + context['upstream_proxy_port'] |
| 352 | smc['https_proxy'] = 'http://' + context['upstream_proxy_user'] + ':' + context['upstream_proxy_password'] + '@' + context['upstream_proxy_address'] + ':' + context['upstream_proxy_port'] |
| 353 | } else { |
| 354 | smc['http_proxy'] = 'http://' + context['upstream_proxy_address'] + ':' + context['upstream_proxy_port'] |
| 355 | smc['https_proxy'] = 'http://' + context['upstream_proxy_address'] + ':' + context['upstream_proxy_port'] |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | for (i in common.entries(smc)) { |
Denis Egorenko | 815d502 | 2019-07-15 16:01:04 +0400 | [diff] [blame] | 360 | sh "sed -i 's,export ${i[0]}=.*,export ${i[0]}=\${${i[0]}:-\"${i[1]}\"},' user_data" |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 361 | } |
| 362 | |
Denis Egorenko | 032a2b7 | 2019-04-03 14:56:52 +0400 | [diff] [blame] | 363 | // calculate netmask |
Denis Egorenko | 1f131b7 | 2019-04-05 14:42:48 +0400 | [diff] [blame] | 364 | def deployNetworkSubnet = '' |
| 365 | if (context.get('deploy_network_subnet')) { |
| 366 | def subnet = new SubnetUtils(context['deploy_network_subnet']) |
| 367 | deployNetworkSubnet = subnet.getInfo().getNetmask() |
| 368 | } else if (context.get('deploy_network_netmask')) { // case for 2018.4.0 |
| 369 | deployNetworkSubnet = context['deploy_network_netmask'] |
| 370 | } else { |
| 371 | error('Neither context parameter deploy_network_subnet or deploy_network_netmask should be set!') |
| 372 | } |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 373 | // create cfg config-drive |
Denis Egorenko | aeaa013 | 2019-02-25 16:55:08 +0400 | [diff] [blame] | 374 | if (outdateGeneration) { |
azvyagintsev | 06dfe40 | 2019-03-22 17:58:53 +0200 | [diff] [blame] | 375 | args += ["--hostname ${context['salt_master_hostname']}", "${context['salt_master_hostname']}.${context['cluster_domain']}-config.iso"] |
Denis Egorenko | aeaa013 | 2019-02-25 16:55:08 +0400 | [diff] [blame] | 376 | sh "./create-config-drive ${args.join(' ')}" |
| 377 | } else { |
| 378 | args += [ |
| 379 | "--name ${context['salt_master_hostname']}", "--hostname ${context['salt_master_hostname']}.${context['cluster_domain']}", "--clean-up", |
Denis Egorenko | 032a2b7 | 2019-04-03 14:56:52 +0400 | [diff] [blame] | 380 | "--ip ${context['salt_master_management_address']}", "--netmask ${deployNetworkSubnet}", "--gateway ${context['deploy_network_gateway']}", |
Denis Egorenko | aaeda9b | 2019-02-28 20:55:59 +0400 | [diff] [blame] | 381 | "--dns-nameservers ${context['dns_server01']},${context['dns_server02']}" |
Denis Egorenko | aeaa013 | 2019-02-25 16:55:08 +0400 | [diff] [blame] | 382 | ] |
azvyagintsev | c4c047a | 2019-04-04 17:42:48 +0300 | [diff] [blame] | 383 | sh "chmod 0755 create-config-drive.py ; ./create-config-drive.py ${args.join(' ')}" |
Denis Egorenko | aeaa013 | 2019-02-25 16:55:08 +0400 | [diff] [blame] | 384 | } |
Aleksey Zvyagintsev | aa235f2 | 2019-04-24 12:46:42 +0000 | [diff] [blame] | 385 | sh("mkdir output-${context['cluster_name']} && mv ${context['salt_master_hostname']}.${context['cluster_domain']}-config.iso output-${context['cluster_name']}/") |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 386 | |
| 387 | // save cfg iso to artifacts |
Aleksey Zvyagintsev | aa235f2 | 2019-04-24 12:46:42 +0000 | [diff] [blame] | 388 | archiveArtifacts artifacts: "output-${context['cluster_name']}/${context['salt_master_hostname']}.${context['cluster_domain']}-config.iso" |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 389 | |
| 390 | if (context['local_repositories'] == 'True') { |
Ivan Berezovskiy | f590bc6 | 2020-02-28 17:29:17 +0400 | [diff] [blame] | 391 | aptlyServerHostname = context.aptly_server_hostname |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 392 | 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" |
| 393 | |
| 394 | def smc_apt = [:] |
| 395 | smc_apt['SALT_MASTER_DEPLOY_IP'] = context['salt_master_management_address'] |
Denis Egorenko | aeaa013 | 2019-02-25 16:55:08 +0400 | [diff] [blame] | 396 | if (outdateGeneration) { |
| 397 | smc_apt['APTLY_DEPLOY_IP'] = context['aptly_server_deploy_address'] |
| 398 | smc_apt['APTLY_DEPLOY_NETMASK'] = context['deploy_network_netmask'] |
| 399 | } |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 400 | smc_apt['APTLY_MINION_ID'] = "${aptlyServerHostname}.${context['cluster_domain']}" |
| 401 | |
| 402 | for (i in common.entries(smc_apt)) { |
| 403 | sh "sed -i \"s,export ${i[0]}=.*,export ${i[0]}=${i[1]},\" mirror_config" |
| 404 | } |
| 405 | |
| 406 | // create apt config-drive |
Denis Egorenko | aeaa013 | 2019-02-25 16:55:08 +0400 | [diff] [blame] | 407 | if (outdateGeneration) { |
| 408 | sh "./create-config-drive --user-data mirror_config --hostname ${aptlyServerHostname} ${aptlyServerHostname}.${context['cluster_domain']}-config.iso" |
| 409 | } else { |
| 410 | args = [ |
Denis Egorenko | 032a2b7 | 2019-04-03 14:56:52 +0400 | [diff] [blame] | 411 | "--ip ${context['aptly_server_deploy_address']}", "--netmask ${deployNetworkSubnet}", "--gateway ${context['deploy_network_gateway']}", |
Denis Egorenko | aaeda9b | 2019-02-28 20:55:59 +0400 | [diff] [blame] | 412 | "--user-data mirror_config", "--hostname ${aptlyServerHostname}.${context['cluster_domain']}", "--name ${aptlyServerHostname}", "--clean-up", |
| 413 | "--dns-nameservers ${context['dns_server01']},${context['dns_server02']}" |
Denis Egorenko | aeaa013 | 2019-02-25 16:55:08 +0400 | [diff] [blame] | 414 | ] |
| 415 | sh "python ./create-config-drive.py ${args.join(' ')}" |
| 416 | } |
Aleksey Zvyagintsev | aa235f2 | 2019-04-24 12:46:42 +0000 | [diff] [blame] | 417 | sh("mv ${aptlyServerHostname}.${context['cluster_domain']}-config.iso output-${context['cluster_name']}/") |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 418 | |
| 419 | // save apt iso to artifacts |
Aleksey Zvyagintsev | aa235f2 | 2019-04-24 12:46:42 +0000 | [diff] [blame] | 420 | archiveArtifacts artifacts: "output-${context['cluster_name']}/${aptlyServerHostname}.${context['cluster_domain']}-config.iso" |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 421 | } |
| 422 | } |
| 423 | |
| 424 | stage('Save changes reclass model') { |
Denis Egorenko | d986525 | 2019-04-24 15:41:57 +0400 | [diff] [blame] | 425 | sh(returnStatus: true, script: "tar -czf ${context['cluster_name']}.tar.gz --exclude='*@tmp' -C ${modelEnv} .") |
| 426 | archiveArtifacts artifacts: "${context['cluster_name']}.tar.gz" |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 427 | |
azvyagintsev | 5400d1d | 2018-12-11 13:19:29 +0200 | [diff] [blame] | 428 | if (RequesterEmail != '' && !RequesterEmail.contains('example')) { |
Denis Egorenko | f972984 | 2019-07-08 15:53:01 +0400 | [diff] [blame] | 429 | def mailSubject = "Your Salt model ${context['cluster_name']}" |
| 430 | if (context.get('send_method') == 'gcs') { |
| 431 | def gcs = new com.mirantis.mk.GoogleCloudStorage() |
| 432 | def uploadIsos = [ "output-${context['cluster_name']}/${context['salt_master_hostname']}.${context['cluster_domain']}-config.iso" ] |
| 433 | if (context['local_repositories'] == 'True') { |
| 434 | uploadIsos << "output-${context['cluster_name']}/${aptlyServerHostname}.${context['cluster_domain']}-config.iso" |
| 435 | } |
| 436 | // generate random hash to have uniq and unpredictable link to file |
| 437 | def randHash = common.generateRandomHashString(64) |
| 438 | def config = [ |
| 439 | 'creds': context['gcs_creds'], |
| 440 | 'project': context['gcs_project'], |
| 441 | 'dest': "gs://${context['gcs_bucket']}/${randHash}", |
| 442 | 'sources': uploadIsos |
| 443 | ] |
| 444 | def fileURLs = gcs.uploadArtifactToGoogleStorageBucket(config).join(' ').replace('gs://', 'https://storage.googleapis.com/') |
| 445 | emailext(to: RequesterEmail, |
| 446 | body: "Mirantis Jenkins\n\nRequested reclass model ${context['cluster_name']} has been created and available to download via next URL: ${fileURLs} within 7 days.\nEnjoy!\n\nMirantis", |
| 447 | subject: mailSubject) |
| 448 | } else { |
| 449 | emailext(to: RequesterEmail, |
| 450 | attachmentsPattern: "output-${context['cluster_name']}/*", |
| 451 | body: "Mirantis Jenkins\n\nRequested reclass model ${context['cluster_name']} has been created and attached to this email.\nEnjoy!\n\nMirantis", |
| 452 | subject: mailSubject) |
| 453 | } |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 454 | } |
Aleksey Zvyagintsev | aa235f2 | 2019-04-24 12:46:42 +0000 | [diff] [blame] | 455 | dir("output-${context['cluster_name']}") { |
| 456 | deleteDir() |
| 457 | } |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | // Fail, but leave possibility to get failed artifacts |
azvyagintsev | 6d678da | 2018-11-28 21:19:06 +0200 | [diff] [blame] | 461 | if (!testResult && runTestModel) { |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 462 | common.warningMsg('Test finished: FAILURE. Please check logs and\\or debug failed model manually!') |
| 463 | error('Test stage finished: FAILURE') |
| 464 | } |
| 465 | |
| 466 | } catch (Throwable e) { |
| 467 | currentBuild.result = "FAILURE" |
| 468 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 469 | throw e |
| 470 | } finally { |
| 471 | stage('Clean workspace directories') { |
Aleksey Zvyagintsev | 7ca28d2 | 2019-02-25 11:05:49 +0000 | [diff] [blame] | 472 | sh(script: 'find . -mindepth 1 -delete > /dev/null || true') |
Aleksey Zvyagintsev | b16902d | 2018-10-29 12:33:48 +0000 | [diff] [blame] | 473 | } |
| 474 | // common.sendNotification(currentBuild.result,"",["slack"]) |
Denis Egorenko | 34c4a3b | 2019-03-12 12:48:15 +0400 | [diff] [blame] | 475 | stage('Save artifacts to Artifactory') { |
Hanna Arhipova | 5132ed4 | 2021-09-08 12:30:37 +0300 | [diff] [blame] | 476 | if (saveToArtifactory) { |
| 477 | def artifactory = new com.mirantis.mcp.MCPArtifactory() |
| 478 | def buildProps = ["context=${context['cluster_name']}"] |
| 479 | if (RequesterEmail != '' && !RequesterEmail.contains('example')) { |
| 480 | buildProps.add("emailTo=${RequesterEmail}") |
| 481 | } |
| 482 | def artifactoryLink = artifactory.uploadJobArtifactsToArtifactory([ |
| 483 | 'artifactory' : 'mcp-ci', |
| 484 | 'artifactoryRepo': "artifactory/drivetrain-local/${JOB_NAME}/${context['cluster_name']}-${BUILD_NUMBER}", |
| 485 | 'buildProps' : buildProps, |
| 486 | ]) |
| 487 | currentBuild.description += "<br/>${artifactoryLink}" |
Denis Egorenko | 34c4a3b | 2019-03-12 12:48:15 +0400 | [diff] [blame] | 488 | } |
Denis Egorenko | 34c4a3b | 2019-03-12 12:48:15 +0400 | [diff] [blame] | 489 | } |
Ruslan Kamaldinov | 6feef40 | 2017-08-02 16:55:58 +0400 | [diff] [blame] | 490 | } |
Tomáš Kukrál | 7ded364 | 2017-03-27 15:52:51 +0200 | [diff] [blame] | 491 | } |
Mikhail Ivanov | 9f81292 | 2017-11-07 18:52:02 +0400 | [diff] [blame] | 492 | } |