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