| def common = new com.mirantis.mk.Common() |
| def gerrit = new com.mirantis.mk.Gerrit() |
| def ssh = new com.mirantis.mk.Ssh() |
| def git = new com.mirantis.mk.Git() |
| |
| def gerritRef |
| try { |
| gerritRef = GERRIT_REFSPEC |
| } catch (MissingPropertyException e) { |
| gerritRef = null |
| } |
| |
| def systemGitRef, systemGitUrl |
| try { |
| systemGitRef = RECLASS_SYSTEM_GIT_REF |
| systemGitUrl = RECLASS_SYSTEM_GIT_URL |
| } catch (MissingPropertyException e) { |
| systemGitRef = null |
| systemGitUrl = null |
| } |
| |
| node("python") { |
| try{ |
| stage("checkout") { |
| if (gerritRef) { |
| gerrit.gerritPatchsetCheckout ([ |
| credentialsId : CREDENTIALS_ID, |
| gerritRefSpec: GERRIT_REFSPEC, |
| gerritName: GERRIT_NAME, |
| gerritHost: GERRIT_HOST, |
| gerritPort: GERRIT_PORT, |
| gerritProject: GERRIT_PROJECT, |
| gerritBranch: GERRIT_BRANCH, |
| ]) |
| } else { |
| git.checkoutGitRepository('.', GIT_URL, "master", CREDENTIALS_ID) |
| } |
| |
| if (fileExists('classes/system')) { |
| ssh.prepareSshAgentKey(CREDENTIALS_ID) |
| dir('classes/system') { |
| remoteUrl = git.getGitRemote() |
| ssh.ensureKnownHosts(remoteUrl) |
| } |
| ssh.agentSh("git submodule init; git submodule sync; git submodule update --recursive") |
| |
| if (systemGitRef) { |
| common.infoMsg("Fetching alternate system reclass (${systemGitUrl} ${systemGitRef})") |
| dir('classes/system') { |
| ssh.ensureKnownHosts(RECLASS_SYSTEM_GIT_URL) |
| ssh.agentSh("git fetch ${systemGitUrl} ${systemGitRef} && git checkout FETCH_HEAD") |
| } |
| } |
| } |
| } |
| stage("test") { |
| timeout(1440) { |
| wrap([$class: 'AnsiColorBuildWrapper']) { |
| sh("make test") |
| } |
| } |
| } |
| } catch (Throwable e) { |
| // If there was an error or exception thrown, the build failed |
| currentBuild.result = "FAILURE" |
| throw e |
| } finally { |
| common.sendNotification(currentBuild.result,"",["slack"]) |
| } |
| } |