chnyda | d66d6fa | 2017-06-22 09:34:43 +0200 | [diff] [blame] | 1 | |
| 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 Karpin | c0758f3 | 2017-06-23 18:10:24 +0300 | [diff] [blame] | 11 | * FORMULAS_SOURCE |
chnyda | bb6d2a6 | 2017-07-31 14:09:16 +0200 | [diff] [blame^] | 12 | * MAX_CPU_PER_JOB |
chnyda | d66d6fa | 2017-06-22 09:34:43 +0200 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | def common = new com.mirantis.mk.Common() |
| 16 | def gerrit = new com.mirantis.mk.Gerrit() |
chnyda | 4ed3c27 | 2017-06-22 14:50:09 +0200 | [diff] [blame] | 17 | def git = new com.mirantis.mk.Git() |
chnyda | c6092a2 | 2017-06-22 14:47:10 +0200 | [diff] [blame] | 18 | def ssh = new com.mirantis.mk.Ssh() |
chnyda | d66d6fa | 2017-06-22 09:34:43 +0200 | [diff] [blame] | 19 | def saltModelTesting = new com.mirantis.mk.SaltModelTesting() |
| 20 | |
| 21 | def defaultGitRef = DEFAULT_GIT_REF |
| 22 | def defaultGitUrl = DEFAULT_GIT_URL |
| 23 | |
| 24 | def checkouted = false |
| 25 | node("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() |
chnyda | bb6d2a6 | 2017-07-31 14:09:16 +0200 | [diff] [blame^] | 56 | saltModelTesting.setupAndTestNode(NODE_TARGET, EXTRA_FORMULAS, workspace, FORMULAS_SOURCE, FORMULAS_REVISION, MAX_CPU_PER_JOB.toInteger()) |
chnyda | d66d6fa | 2017-06-22 09:34:43 +0200 | [diff] [blame] | 57 | } |
| 58 | } |
| 59 | } catch (Throwable e) { |
| 60 | // If there was an error or exception thrown, the build failed |
| 61 | currentBuild.result = "FAILURE" |
| 62 | throw e |
chnyda | d66d6fa | 2017-06-22 09:34:43 +0200 | [diff] [blame] | 63 | } |
| 64 | } |