blob: e53e652b0484297d80cc1ad1c8c079bde6dc1f97 [file] [log] [blame]
Jakub Josef83379312017-03-29 18:12:34 +02001/**
2 * Test salt formulas pipeline
3 * DEFAULT_GIT_REF
4 * DEFAULT_GIT_URL
5 * CREDENTIALS_ID
6 */
Jakub Josefc5a223a2017-03-01 14:40:08 +01007def common = new com.mirantis.mk.Common()
8def gerrit = new com.mirantis.mk.Gerrit()
Jakub Josef83379312017-03-29 18:12:34 +02009
10def gerritRef
11try {
12 gerritRef = GERRIT_REFSPEC
13} catch (MissingPropertyException e) {
14 gerritRef = null
15}
16
17def defaultGitRef, defaultGitUrl
18try {
19 defaultGitRef = DEFAULT_GIT_REF
20 defaultGitUrl = DEFAULT_GIT_URL
21} catch (MissingPropertyException e) {
22 defaultGitRef = null
23 defaultGitUrl = null
24}
25
26def checkouted = false;
27
Jakub Josefc5a223a2017-03-01 14:40:08 +010028node("python") {
29 try{
30 stage("checkout") {
Jakub Josef83379312017-03-29 18:12:34 +020031 if (gerritRef) {
32 // job is triggered by Gerrit
33 checkouted = gerrit.gerritPatchsetCheckout ([
Jakub Josefc5a223a2017-03-01 14:40:08 +010034 credentialsId : CREDENTIALS_ID
Jakub Josef83379312017-03-29 18:12:34 +020035 ])
36 } else if(defaultGitRef && defaultGitUrl) {
Jakub Josefe1407ac2017-03-30 14:10:19 +020037 checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "HEAD", CREDENTIALS_ID)
Jakub Josef83379312017-03-29 18:12:34 +020038 }
39 if(!checkouted){
Jakub Josef5ce6a362017-03-31 13:41:17 +020040 throw new Exception("Cannot checkout gerrit patchset, GERRIT_REFSPEC and DEFAULT_GIT_REF is null")
Jakub Josef83379312017-03-29 18:12:34 +020041 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010042 }
43 stage("test") {
Jakub Josef83379312017-03-29 18:12:34 +020044 if(checkouted){
45 wrap([$class: 'AnsiColorBuildWrapper']) {
46 sh("make clean")
47 sh("[ $SALT_VERSION != 'latest' ] || export SALT_VERSION=''; make test")
48 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010049 }
50 }
51 } catch (Throwable e) {
52 // If there was an error or exception thrown, the build failed
53 currentBuild.result = "FAILURE"
54 throw e
55 } finally {
56 common.sendNotification(currentBuild.result,"",["slack"])
57 }
58}