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