blob: 185e4c3f51d9997a9886dcdf9606021556fccbd1 [file] [log] [blame]
chnydad66d6fa2017-06-22 09:34:43 +02001
2/**
3 * Test salt models pipeline
4 * DEFAULT_GIT_REF
5 * DEFAULT_GIT_URL
6 * CREDENTIALS_ID
7 * EXTRA_FORMULAS
8 * NODE_TARGET
9 * SYSTEM_GIT_URL
10 * SYSTEM_GIT_REF
Mykyta Karpinc0758f32017-06-23 18:10:24 +030011 * FORMULAS_SOURCE
chnydad66d6fa2017-06-22 09:34:43 +020012 */
13
14def common = new com.mirantis.mk.Common()
15def gerrit = new com.mirantis.mk.Gerrit()
chnyda4ed3c272017-06-22 14:50:09 +020016def git = new com.mirantis.mk.Git()
chnydac6092a22017-06-22 14:47:10 +020017def ssh = new com.mirantis.mk.Ssh()
chnydad66d6fa2017-06-22 09:34:43 +020018def saltModelTesting = new com.mirantis.mk.SaltModelTesting()
19
20def defaultGitRef = DEFAULT_GIT_REF
21def defaultGitUrl = DEFAULT_GIT_URL
22
23def checkouted = false
24node("python") {
25 try{
26 stage("checkout") {
27 if(defaultGitRef != "" && defaultGitUrl != "") {
28 checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "HEAD", CREDENTIALS_ID)
29 } else {
30 throw new Exception("Cannot checkout gerrit patchset, DEFAULT_GIT_URL or DEFAULT_GIT_REF is null")
31 }
32 if(checkouted) {
33 if (fileExists('classes/system')) {
34 if (SYSTEM_GIT_URL == "") {
35 ssh.prepareSshAgentKey(CREDENTIALS_ID)
36 dir('classes/system') {
37 remoteUrl = git.getGitRemote()
38 ssh.ensureKnownHosts(remoteUrl)
39 }
40 ssh.agentSh("git submodule init; git submodule sync; git submodule update --recursive")
41 } else {
42 dir('classes/system') {
43 if (!gerrit.gerritPatchsetCheckout(SYSTEM_GIT_URL, SYSTEM_GIT_REF, "HEAD", CREDENTIALS_ID)) {
44 common.errorMsg("Failed to obtain system reclass with url: ${SYSTEM_GIT_URL} and ${SYSTEM_GIT_REF}")
45 }
46 }
47 }
48 }
49 }
50 }
51
52 stage("test node") {
53 if (checkouted) {
54 def workspace = common.getWorkspace()
Jakub Josef09251c92017-06-27 11:49:33 +020055 saltModelTesting.setupAndTestNode(NODE_TARGET, EXTRA_FORMULAS, workspace, FORMULAS_SOURCE, FORMULAS_REVISION)
chnydad66d6fa2017-06-22 09:34:43 +020056 }
57 }
58 } catch (Throwable e) {
59 // If there was an error or exception thrown, the build failed
60 currentBuild.result = "FAILURE"
61 throw e
chnydad66d6fa2017-06-22 09:34:43 +020062 }
63}