Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 1 | def common = new com.mirantis.mk.Common() |
| 2 | def gerrit = new com.mirantis.mk.Gerrit() |
Filip Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 3 | def ssh = new com.mirantis.mk.Ssh() |
| 4 | def git = new com.mirantis.mk.Git() |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 5 | |
Filip Pytloun | 19376a8 | 2017-03-07 12:29:00 +0100 | [diff] [blame] | 6 | def gerritRef |
| 7 | try { |
| 8 | gerritRef = GERRIT_REFSPEC |
| 9 | } catch (MissingPropertyException e) { |
| 10 | gerritRef = null |
| 11 | } |
| 12 | |
Filip Pytloun | 840a084 | 2017-03-07 13:54:23 +0100 | [diff] [blame^] | 13 | def systemGitRef, systemGitUrl |
Filip Pytloun | 19376a8 | 2017-03-07 12:29:00 +0100 | [diff] [blame] | 14 | try { |
Filip Pytloun | 840a084 | 2017-03-07 13:54:23 +0100 | [diff] [blame^] | 15 | systemGitRef = RECLASS_SYSTEM_GIT_REF |
| 16 | systemGitUrl = RECLASS_SYSTEM_GIT_URL |
Filip Pytloun | 19376a8 | 2017-03-07 12:29:00 +0100 | [diff] [blame] | 17 | } catch (MissingPropertyException e) { |
| 18 | systemGitRef = null |
| 19 | systemGitUrl = null |
| 20 | } |
| 21 | |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 22 | node("python") { |
| 23 | try{ |
| 24 | stage("checkout") { |
Filip Pytloun | 19376a8 | 2017-03-07 12:29:00 +0100 | [diff] [blame] | 25 | if (gerritRef) { |
| 26 | gerrit.gerritPatchsetCheckout ([ |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 27 | credentialsId : CREDENTIALS_ID |
Filip Pytloun | 19376a8 | 2017-03-07 12:29:00 +0100 | [diff] [blame] | 28 | ]) |
| 29 | } else { |
| 30 | git.checkoutGitRepository('.', GIT_URL, "master", CREDENTIALS_ID) |
| 31 | } |
Filip Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 32 | |
Filip Pytloun | b1037a6 | 2017-03-06 11:27:13 +0100 | [diff] [blame] | 33 | if (fileExists('classes/system')) { |
Filip Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 34 | 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 Pytloun | 19376a8 | 2017-03-07 12:29:00 +0100 | [diff] [blame] | 40 | |
| 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 Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 48 | } |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 49 | } |
| 50 | stage("test") { |
Filip Pytloun | 3f3829d | 2017-03-06 12:13:14 +0100 | [diff] [blame] | 51 | timeout(10800) { |
| 52 | wrap([$class: 'AnsiColorBuildWrapper']) { |
| 53 | sh("make test") |
| 54 | } |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 55 | } |
| 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 Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 64 | } |