blob: 7ac0e81b57a0599396fa19d34d625b129ed70167 [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 Josef9d028e72017-03-23 11:40:49 +010027 credentialsId : CREDENTIALS_ID,
28 gerritRefSpec: GERRIT_REFSPEC,
29 gerritName: GERRIT_NAME,
30 gerritHost: GERRIT_HOST,
31 gerritPort: GERRIT_PORT,
32 gerritProject: GERRIT_PROJECT,
33 gerritBranch: GERRIT_BRANCH,
Filip Pytloun19376a82017-03-07 12:29:00 +010034 ])
35 } else {
36 git.checkoutGitRepository('.', GIT_URL, "master", CREDENTIALS_ID)
37 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010038
Filip Pytlounb1037a62017-03-06 11:27:13 +010039 if (fileExists('classes/system')) {
Filip Pytloun38005aa2017-03-06 10:26:38 +010040 ssh.prepareSshAgentKey(CREDENTIALS_ID)
41 dir('classes/system') {
42 remoteUrl = git.getGitRemote()
43 ssh.ensureKnownHosts(remoteUrl)
44 }
45 ssh.agentSh("git submodule init; git submodule sync; git submodule update --recursive")
Filip Pytloun19376a82017-03-07 12:29:00 +010046
47 if (systemGitRef) {
48 common.infoMsg("Fetching alternate system reclass (${systemGitUrl} ${systemGitRef})")
49 dir('classes/system') {
50 ssh.ensureKnownHosts(RECLASS_SYSTEM_GIT_URL)
51 ssh.agentSh("git fetch ${systemGitUrl} ${systemGitRef} && git checkout FETCH_HEAD")
52 }
53 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010054 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010055 }
56 stage("test") {
Jakub Josef9d028e72017-03-23 11:40:49 +010057 timeout(1440) {
Filip Pytloun3f3829d2017-03-06 12:13:14 +010058 wrap([$class: 'AnsiColorBuildWrapper']) {
59 sh("make test")
60 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010061 }
62 }
63 } catch (Throwable e) {
64 // If there was an error or exception thrown, the build failed
65 currentBuild.result = "FAILURE"
66 throw e
67 } finally {
68 common.sendNotification(currentBuild.result,"",["slack"])
69 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010070}