blob: 1a31f8822d4d3e2b80bf4ac7c3dc2df59e5e76c4 [file] [log] [blame]
Jakub Josef83379312017-03-29 18:12:34 +02001
2/**
3 * Test salt models pipeline
4 * DEFAULT_GIT_REF
5 * DEFAULT_GIT_URL
6 * CREDENTIALS_ID
7 */
8
Jakub Josefc5a223a2017-03-01 14:40:08 +01009def common = new com.mirantis.mk.Common()
10def gerrit = new com.mirantis.mk.Gerrit()
Filip Pytloun38005aa2017-03-06 10:26:38 +010011def ssh = new com.mirantis.mk.Ssh()
12def git = new com.mirantis.mk.Git()
Jakub Josefc5a223a2017-03-01 14:40:08 +010013
Filip Pytloun19376a82017-03-07 12:29:00 +010014def gerritRef
15try {
16 gerritRef = GERRIT_REFSPEC
17} catch (MissingPropertyException e) {
18 gerritRef = null
19}
20
Jakub Josef83379312017-03-29 18:12:34 +020021def defaultGitRef, defaultGitUrl
Filip Pytloun19376a82017-03-07 12:29:00 +010022try {
Jakub Josef83379312017-03-29 18:12:34 +020023 defaultGitRef = DEFAULT_GIT_REF
24 defaultGitUrl = DEFAULT_GIT_URL
Filip Pytloun19376a82017-03-07 12:29:00 +010025} catch (MissingPropertyException e) {
Jakub Josef83379312017-03-29 18:12:34 +020026 defaultGitRef = null
27 defaultGitUrl = null
Filip Pytloun19376a82017-03-07 12:29:00 +010028}
Jakub Josef83379312017-03-29 18:12:34 +020029def checkouted = false
Filip Pytloun19376a82017-03-07 12:29:00 +010030
Jakub Josefc5a223a2017-03-01 14:40:08 +010031node("python") {
32 try{
33 stage("checkout") {
Filip Pytloun19376a82017-03-07 12:29:00 +010034 if (gerritRef) {
Jakub Josef83379312017-03-29 18:12:34 +020035 // job is triggered by Gerrit
36 checkouted = gerrit.gerritPatchsetCheckout ([
37 credentialsId : CREDENTIALS_ID
Filip Pytloun19376a82017-03-07 12:29:00 +010038 ])
Jakub Josef83379312017-03-29 18:12:34 +020039 } else if(defaultGitRef && defaultGitUrl) {
40 checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "master", CREDENTIALS_ID)
Filip Pytloun19376a82017-03-07 12:29:00 +010041 }
Jakub Josef83379312017-03-29 18:12:34 +020042 if(checkouted){
43 if (fileExists('classes/system')) {
44 ssh.prepareSshAgentKey(CREDENTIALS_ID)
Filip Pytloun19376a82017-03-07 12:29:00 +010045 dir('classes/system') {
Jakub Josef83379312017-03-29 18:12:34 +020046 remoteUrl = git.getGitRemote()
47 ssh.ensureKnownHosts(remoteUrl)
Filip Pytloun19376a82017-03-07 12:29:00 +010048 }
Jakub Josef83379312017-03-29 18:12:34 +020049 ssh.agentSh("git submodule init; git submodule sync; git submodule update --recursive")
Filip Pytloun19376a82017-03-07 12:29:00 +010050 }
Jakub Josef83379312017-03-29 18:12:34 +020051 }else{
52 common.errorMsg("Cannot checkout gerrit patchset, GERRIT_REFSPEC and DEFAULT_GIT_REF is null")
Filip Pytloun38005aa2017-03-06 10:26:38 +010053 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010054 }
55 stage("test") {
Jakub Josef83379312017-03-29 18:12:34 +020056 if(checkouted){
57 timeout(1440) {
58 wrap([$class: 'AnsiColorBuildWrapper']) {
59 sh("make test")
60 }
Filip Pytloun3f3829d2017-03-06 12:13:14 +010061 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010062 }
63 }
64 } catch (Throwable e) {
65 // If there was an error or exception thrown, the build failed
66 currentBuild.result = "FAILURE"
67 throw e
68 } finally {
69 common.sendNotification(currentBuild.result,"",["slack"])
70 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010071}