blob: f3b89dc35741c0ada0722f9643c1e56c0b1b655f [file] [log] [blame]
Jakub Joseff2a66e92017-03-08 17:21:07 +01001/**
2 * Gerrit gating pipeline
3 * CREDENTIALS_ID - Gerrit credentails ID
4 *
5**/
6
7def common = new com.mirantis.mk.Common()
8def gerrit = new com.mirantis.mk.Gerrit()
Jakub Josefeda07682017-03-09 14:50:54 +01009def ssh = new com.mirantis.mk.Ssh()
Jakub Joseff2a66e92017-03-08 17:21:07 +010010node("python") {
11 try{
12 stage("test") {
Jakub Joseff2a66e92017-03-08 17:21:07 +010013 wrap([$class: 'AnsiColorBuildWrapper']) {
Jakub Josefa722d432017-03-10 12:43:00 +010014 if(TEST_JOBS != ""){
15 def testJobs = TEST_JOBS.tokenize(" ")
16 for(int i=0; i<testJobs.size(); i++){
17 build job: testJobs.get(i), parameters: [
18 [$class: 'StringParameterValue', name: 'GERRIT_BRANCH', value: GERRIT_BRANCH],
19 [$class: 'StringParameterValue', name: 'GERRIT_NAME', value: GERRIT_NAME],
20 [$class: 'StringParameterValue', name: 'GERRIT_HOST', value: GERRIT_HOST],
21 [$class: 'StringParameterValue', name: 'GERRIT_PORT', value: GERRIT_PORT],
22 [$class: 'StringParameterValue', name: 'GERRIT_PROJECT', value: GERRIT_PROJECT],
23 [$class: 'StringParameterValue', name: 'GERRIT_REFSPEC', value: GERRIT_REFSPEC]
24 ]
25 }
26 }
27 }
Jakub Joseff2a66e92017-03-08 17:21:07 +010028 }
29 stage("submit review"){
30 ssh.prepareSshAgentKey(CREDENTIALS_ID)
31 ssh.ensureKnownHosts(GERRIT_HOST)
Jakub Josefcec301b2017-03-09 15:10:22 +010032 ssh.agentSh(String.format("ssh -p 29418 %s@%s gerrit review --submit %s,%s", GERRIT_NAME, GERRIT_HOST, GERRIT_CHANGE_NUMBER, GERRIT_PATCHSET_NUMBER))
Jakub Joseff2a66e92017-03-08 17:21:07 +010033 println(String.format("Gerrit review %s,%s submitted", GERRIT_CHANGE_NUMBER, GERRIT_PATCHSET_NUMBER))
Jakub Joseffd91d1f2017-03-08 17:27:41 +010034 }
Jakub Joseff2a66e92017-03-08 17:21:07 +010035 } catch (Throwable e) {
36 // If there was an error or exception thrown, the build failed
37 currentBuild.result = "FAILURE"
38 throw e
39 } finally {
40 common.sendNotification(currentBuild.result,"",["slack"])
41 }
42}