blob: 920e7914d23753526434be343eb9338ae735d8d8 [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 Joseff64c6392017-05-03 13:18:25 +02009def ruby = new com.mirantis.mk.Ruby()
Jakub Josef83379312017-03-29 18:12:34 +020010
11def gerritRef
12try {
13 gerritRef = GERRIT_REFSPEC
14} catch (MissingPropertyException e) {
15 gerritRef = null
16}
17
18def defaultGitRef, defaultGitUrl
19try {
20 defaultGitRef = DEFAULT_GIT_REF
21 defaultGitUrl = DEFAULT_GIT_URL
22} catch (MissingPropertyException e) {
23 defaultGitRef = null
24 defaultGitUrl = null
25}
26
27def checkouted = false;
28
Jakub Josef52baaa42017-05-04 12:20:54 +020029node("python&&docker") {
Jakub Josefc5a223a2017-03-01 14:40:08 +010030 try{
31 stage("checkout") {
Jakub Josef83379312017-03-29 18:12:34 +020032 if (gerritRef) {
33 // job is triggered by Gerrit
34 checkouted = gerrit.gerritPatchsetCheckout ([
Jakub Josefc5a223a2017-03-01 14:40:08 +010035 credentialsId : CREDENTIALS_ID
Jakub Josef83379312017-03-29 18:12:34 +020036 ])
37 } else if(defaultGitRef && defaultGitUrl) {
Jakub Josefe1407ac2017-03-30 14:10:19 +020038 checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "HEAD", CREDENTIALS_ID)
Jakub Josef83379312017-03-29 18:12:34 +020039 }
40 if(!checkouted){
Jakub Josef5ce6a362017-03-31 13:41:17 +020041 throw new Exception("Cannot checkout gerrit patchset, GERRIT_REFSPEC and DEFAULT_GIT_REF is null")
Jakub Josef83379312017-03-29 18:12:34 +020042 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010043 }
44 stage("test") {
Jakub Josef83379312017-03-29 18:12:34 +020045 if(checkouted){
46 wrap([$class: 'AnsiColorBuildWrapper']) {
47 sh("make clean")
48 sh("[ $SALT_VERSION != 'latest' ] || export SALT_VERSION=''; make test")
49 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010050 }
51 }
Jakub Joseff64c6392017-05-03 13:18:25 +020052 stage("kitchen") {
53 if (fileExists(".kitchen.yml")) {
Jakub Josef52baaa42017-05-04 12:20:54 +020054 common.infoMsg(".kitchen.yml found, running kitchen tests")
Jakub Joseff64c6392017-05-03 13:18:25 +020055 ruby.ensureRubyEnv()
56 ruby.installKitchen()
57 wrap([$class: 'AnsiColorBuildWrapper']) {
58 ruby.runKitchenTests()
59 }
60 } else {
61 common.infoMsg(".kitchen.yml not found")
62 }
63 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010064 } catch (Throwable e) {
65 // If there was an error or exception thrown, the build failed
66 currentBuild.result = "FAILURE"
67 throw e
68 } finally {
Jakub Josef52baaa42017-05-04 12:20:54 +020069 if(currentBuild.result == "FAILURE" && fileExists(".kitchen/logs/kitchen.log")){
Jakub Joseff96ebc52017-05-04 12:37:19 +020070 common.errorMsg("----------------KITCHEN LOG:---------------")
Jakub Josef52baaa42017-05-04 12:20:54 +020071 println readFile(".kitchen/logs/kitchen.log")
72 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010073 common.sendNotification(currentBuild.result,"",["slack"])
74 }
75}