blob: de4110d1b0a6f7bc9c147436f05051316913bbfa [file] [log] [blame]
Jakub Josefc5a223a2017-03-01 14:40:08 +01001def common = new com.mirantis.mk.Common()
2def gerrit = new com.mirantis.mk.Gerrit()
Filip Pytloun38005aa2017-03-06 10:26:38 +01003def ssh = new com.mirantis.mk.Ssh()
4def git = new com.mirantis.mk.Git()
Jakub Josefc5a223a2017-03-01 14:40:08 +01005
Filip Pytloun19376a82017-03-07 12:29:00 +01006def gerritRef
7try {
8 gerritRef = GERRIT_REFSPEC
9} catch (MissingPropertyException e) {
10 gerritRef = null
11}
12
13try {
14 systemGitRef = RECLAS_SYSTEM_GIT_REF
15 systemGitUrl = RECLAS_SYSTEM_GIT_URL
16} catch (MissingPropertyException e) {
17 systemGitRef = null
18 systemGitUrl = null
19}
20
Jakub Josefc5a223a2017-03-01 14:40:08 +010021node("python") {
22 try{
23 stage("checkout") {
Filip Pytloun19376a82017-03-07 12:29:00 +010024 if (gerritRef) {
25 gerrit.gerritPatchsetCheckout ([
Jakub Josefc5a223a2017-03-01 14:40:08 +010026 credentialsId : CREDENTIALS_ID
Filip Pytloun19376a82017-03-07 12:29:00 +010027 ])
28 } else {
29 git.checkoutGitRepository('.', GIT_URL, "master", CREDENTIALS_ID)
30 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010031
Filip Pytlounb1037a62017-03-06 11:27:13 +010032 if (fileExists('classes/system')) {
Filip Pytloun38005aa2017-03-06 10:26:38 +010033 ssh.prepareSshAgentKey(CREDENTIALS_ID)
34 dir('classes/system') {
35 remoteUrl = git.getGitRemote()
36 ssh.ensureKnownHosts(remoteUrl)
37 }
38 ssh.agentSh("git submodule init; git submodule sync; git submodule update --recursive")
Filip Pytloun19376a82017-03-07 12:29:00 +010039
40 if (systemGitRef) {
41 common.infoMsg("Fetching alternate system reclass (${systemGitUrl} ${systemGitRef})")
42 dir('classes/system') {
43 ssh.ensureKnownHosts(RECLASS_SYSTEM_GIT_URL)
44 ssh.agentSh("git fetch ${systemGitUrl} ${systemGitRef} && git checkout FETCH_HEAD")
45 }
46 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010047 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010048 }
49 stage("test") {
Filip Pytloun3f3829d2017-03-06 12:13:14 +010050 timeout(10800) {
51 wrap([$class: 'AnsiColorBuildWrapper']) {
52 sh("make test")
53 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010054 }
55 }
56 } catch (Throwable e) {
57 // If there was an error or exception thrown, the build failed
58 currentBuild.result = "FAILURE"
59 throw e
60 } finally {
61 common.sendNotification(currentBuild.result,"",["slack"])
62 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010063}