blob: a2e692310c92d21e3499f45b3b3596dc68fecd2d [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
chnydabb6d2a62017-07-31 14:09:16 +020012 * MAX_CPU_PER_JOB
chnydad66d6fa2017-06-22 09:34:43 +020013 */
14
15def common = new com.mirantis.mk.Common()
16def gerrit = new com.mirantis.mk.Gerrit()
chnyda4ed3c272017-06-22 14:50:09 +020017def git = new com.mirantis.mk.Git()
chnydac6092a22017-06-22 14:47:10 +020018def ssh = new com.mirantis.mk.Ssh()
chnydad66d6fa2017-06-22 09:34:43 +020019def saltModelTesting = new com.mirantis.mk.SaltModelTesting()
20
21def defaultGitRef = DEFAULT_GIT_REF
22def defaultGitUrl = DEFAULT_GIT_URL
23
24def checkouted = false
25node("python") {
26 try{
27 stage("checkout") {
28 if(defaultGitRef != "" && defaultGitUrl != "") {
29 checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "HEAD", CREDENTIALS_ID)
30 } else {
31 throw new Exception("Cannot checkout gerrit patchset, DEFAULT_GIT_URL or DEFAULT_GIT_REF is null")
32 }
33 if(checkouted) {
34 if (fileExists('classes/system')) {
35 if (SYSTEM_GIT_URL == "") {
36 ssh.prepareSshAgentKey(CREDENTIALS_ID)
37 dir('classes/system') {
38 remoteUrl = git.getGitRemote()
39 ssh.ensureKnownHosts(remoteUrl)
40 }
41 ssh.agentSh("git submodule init; git submodule sync; git submodule update --recursive")
42 } else {
43 dir('classes/system') {
44 if (!gerrit.gerritPatchsetCheckout(SYSTEM_GIT_URL, SYSTEM_GIT_REF, "HEAD", CREDENTIALS_ID)) {
45 common.errorMsg("Failed to obtain system reclass with url: ${SYSTEM_GIT_URL} and ${SYSTEM_GIT_REF}")
46 }
47 }
48 }
49 }
50 }
51 }
52
53 stage("test node") {
54 if (checkouted) {
55 def workspace = common.getWorkspace()
chnydabb6d2a62017-07-31 14:09:16 +020056 saltModelTesting.setupAndTestNode(NODE_TARGET, EXTRA_FORMULAS, workspace, FORMULAS_SOURCE, FORMULAS_REVISION, MAX_CPU_PER_JOB.toInteger())
chnydad66d6fa2017-06-22 09:34:43 +020057 }
58 }
59 } catch (Throwable e) {
60 // If there was an error or exception thrown, the build failed
61 currentBuild.result = "FAILURE"
62 throw e
chnydad66d6fa2017-06-22 09:34:43 +020063 }
64}