blob: bac97fb8effe4c0143362fb52be4395d62ab7bc8 [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
Filip Pytloun840a0842017-03-07 13:54:23 +010013def systemGitRef, systemGitUrl
Filip Pytloun19376a82017-03-07 12:29:00 +010014try {
Filip Pytloun840a0842017-03-07 13:54:23 +010015 systemGitRef = RECLASS_SYSTEM_GIT_REF
16 systemGitUrl = RECLASS_SYSTEM_GIT_URL
Filip Pytloun19376a82017-03-07 12:29:00 +010017} catch (MissingPropertyException e) {
18 systemGitRef = null
19 systemGitUrl = null
20}
21
Jakub Josefc5a223a2017-03-01 14:40:08 +010022node("python") {
23 try{
24 stage("checkout") {
Filip Pytloun19376a82017-03-07 12:29:00 +010025 if (gerritRef) {
26 gerrit.gerritPatchsetCheckout ([
Jakub Josefc5a223a2017-03-01 14:40:08 +010027 credentialsId : CREDENTIALS_ID
Filip Pytloun19376a82017-03-07 12:29:00 +010028 ])
29 } else {
30 git.checkoutGitRepository('.', GIT_URL, "master", CREDENTIALS_ID)
31 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010032
Filip Pytlounb1037a62017-03-06 11:27:13 +010033 if (fileExists('classes/system')) {
Filip Pytloun38005aa2017-03-06 10:26:38 +010034 ssh.prepareSshAgentKey(CREDENTIALS_ID)
35 dir('classes/system') {
36 remoteUrl = git.getGitRemote()
37 ssh.ensureKnownHosts(remoteUrl)
38 }
39 ssh.agentSh("git submodule init; git submodule sync; git submodule update --recursive")
Filip Pytloun19376a82017-03-07 12:29:00 +010040
41 if (systemGitRef) {
42 common.infoMsg("Fetching alternate system reclass (${systemGitUrl} ${systemGitRef})")
43 dir('classes/system') {
44 ssh.ensureKnownHosts(RECLASS_SYSTEM_GIT_URL)
45 ssh.agentSh("git fetch ${systemGitUrl} ${systemGitRef} && git checkout FETCH_HEAD")
46 }
47 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010048 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010049 }
50 stage("test") {
Filip Pytloun3f3829d2017-03-06 12:13:14 +010051 timeout(10800) {
52 wrap([$class: 'AnsiColorBuildWrapper']) {
53 sh("make test")
54 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010055 }
56 }
57 } catch (Throwable e) {
58 // If there was an error or exception thrown, the build failed
59 currentBuild.result = "FAILURE"
60 throw e
61 } finally {
62 common.sendNotification(currentBuild.result,"",["slack"])
63 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010064}