blob: 5c83eeea269285df955a2bbbe6b2eb918f2e7b64 [file] [log] [blame]
Ales Komarek1ebb7a82017-08-04 14:58:51 +02001
2/**
3 * Rollout changes to the node(s) configuration
4 *
5 * Expected parameters:
6 * TST_SALT_MASTER_CREDENTIALS Credentials to the Salt API (QA environment).
7 * TST_SALT_MASTER_URL Full Salt API address [https://10.10.10.1:8000].
8 * PRD_SALT_MASTER_CREDENTIALS Credentials to the Salt API (PRD environment).
9 * PRD_SALT_MASTER_URL Full Salt API address [https://10.10.10.1:8000].
10 * Model parameters:
11 * MODEL_REPO_CREDENTIALS Credentials to the Model.
12 * MODEL_REPO_URL Full model repo address.
13 * MODEL_REPO_SOURCE_BRANCH Source branch to merge from.
14 * MODEL_REPO_TARGET_BRANCH Target branch to merge fo.
15 * Change settings:
16 * TARGET_SERVERS Salt compound target to match nodes to be updated [*, G@osfamily:debian].
17 * TARGET_STATES States to be applied, empty string means running highstate [linux, linux,openssh, salt.minion.grains].
18 * TARGET_SUBSET_TEST Number of nodes to test config changes, empty string means all targetted nodes.
19 * TARGET_SUBSET_LIVE Number of selected noded to live apply selected config changes.
20 * TARGET_BATCH_LIVE Batch size for the complete live config changes on all nodes, empty string means apply to all targetted nodes.
21 * Test settings:
22 * TEST_SERVICE Comma separated list of services to test
23 * TEST_K8S_API_SERVER Kubernetes API address
24 * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
25 * TEST_DOCKER_INSTALL Install docker on the target if true
26 * TEST_TEMPEST_IMAGE Tempest image link
27 * TEST_TEMPEST_PATTERN If not false, run tests matched to pattern only
28 * TEST_TEMPEST_TARGET Salt target for tempest node
29 *
30**/
31
32def common = new com.mirantis.mk.Common()
33def salt = new com.mirantis.mk.Salt()
34
35node() {
36 try {
37
38 stage('Run config change on test env') {
39 build job: "deploy-update-service-config", parameters: [
40 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: TST_SALT_MASTER_URL],
41 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: TST_SALT_MASTER_CREDENTIALS],
42 [$class: 'StringParameterValue', name: 'TARGET_BATCH_LIVE', value: TARGET_BATCH_LIVE],
43 [$class: 'StringParameterValue', name: 'TARGET_SERVERS', value: TARGET_SERVERS],
44 [$class: 'StringParameterValue', name: 'TARGET_STATES', value: TARGET_STATES],
45 [$class: 'StringParameterValue', name: 'TARGET_SUBSET_LIVE', value: TARGET_SUBSET_LIVE],
46 [$class: 'StringParameterValue', name: 'TARGET_SUBSET_TEST', value: TARGET_SUBSET_TEST],
47 ]
48 }
49
50 stage('Test config change on test env') {
51 build job: "deploy-test-service", parameters: [
52 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: TST_SALT_MASTER_URL],
53 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: TST_SALT_MASTER_CREDENTIALS],
54 [$class: 'StringParameterValue', name: 'TEST_SERVICE', value: TEST_SERVICE],
55 [$class: 'StringParameterValue', name: 'TEST_K8S_API_SERVER', value: TEST_K8S_API_SERVER],
56 [$class: 'StringParameterValue', name: 'TEST_K8S_CONFORMANCE_IMAGE', value: TEST_K8S_CONFORMANCE_IMAGE],
57 ]
58 }
59
60 stage('Promote config change in repo') {
Jakub Josefb08a94b2017-08-16 13:54:28 +020061 build job: "git-merge-branches", parameters: [
62 [$class: 'StringParameterValue', name: 'REPO_URL', value: MODEL_REPO_URL],
63 [$class: 'StringParameterValue', name: 'CREDENTIALS_ID', value: MODEL_REPO_CREDENTIALS],
64 [$class: 'StringParameterValue', name: 'SOURCE_BRANCH', value: MODEL_REPO_SOURCE_BRANCH],
65 [$class: 'StringParameterValue', name: 'TARGET_BRANCH', value: MODEL_REPO_TARGET_BRANCH],
Ales Komarek1ebb7a82017-08-04 14:58:51 +020066 ]
67 }
68
69 stage('Run config change on production env') {
70 build job: "deploy-update-service-config", parameters: [
71 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: PRD_SALT_MASTER_URL],
72 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: PRD_SALT_MASTER_CREDENTIALS],
73 [$class: 'StringParameterValue', name: 'TARGET_BATCH_LIVE', value: TARGET_BATCH_LIVE],
74 [$class: 'StringParameterValue', name: 'TARGET_SERVERS', value: TARGET_SERVERS],
75 [$class: 'StringParameterValue', name: 'TARGET_STATES', value: TARGET_STATES],
76 [$class: 'StringParameterValue', name: 'TARGET_SUBSET_LIVE', value: TARGET_SUBSET_LIVE],
77 [$class: 'StringParameterValue', name: 'TARGET_SUBSET_TEST', value: TARGET_SUBSET_TEST],
78 ]
79 }
80
81 stage('Test config change on prod env') {
Jakub Josefb08a94b2017-08-16 13:54:28 +020082 def result = build job: "deploy-test-service", parameters: [
Ales Komarek1ebb7a82017-08-04 14:58:51 +020083 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: PRD_SALT_MASTER_URL],
84 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: PRD_SALT_MASTER_CREDENTIALS],
85 [$class: 'StringParameterValue', name: 'TEST_SERVICE', value: TEST_SERVICE],
86 [$class: 'StringParameterValue', name: 'TEST_K8S_API_SERVER', value: TEST_K8S_API_SERVER],
87 [$class: 'StringParameterValue', name: 'TEST_K8S_CONFORMANCE_IMAGE', value: TEST_K8S_CONFORMANCE_IMAGE],
88 ]
89 }
90
91 } catch (Throwable e) {
92 currentBuild.result = 'FAILURE'
93 throw e
94 }
95}