Jakub Josef | f2a66e9 | 2017-03-08 17:21:07 +0100 | [diff] [blame^] | 1 | /** |
| 2 | * Gerrit gating pipeline |
| 3 | * CREDENTIALS_ID - Gerrit credentails ID |
| 4 | * |
| 5 | **/ |
| 6 | |
| 7 | def common = new com.mirantis.mk.Common() |
| 8 | def gerrit = new com.mirantis.mk.Gerrit() |
| 9 | def ssh = new com.mirantis.mk.Salt() |
| 10 | node("python") { |
| 11 | try{ |
| 12 | stage("test") { |
| 13 | /* |
| 14 | wrap([$class: 'AnsiColorBuildWrapper']) { |
| 15 | build job: "test-${GERRIT_PROJECT}", parameters: [ |
| 16 | [$class: 'StringParameterValue', name: 'GERRIT_BRANCH', value: GERRIT_BRANCH], |
| 17 | [$class: 'StringParameterValue', name: 'GERRIT_NAME', value: GERRIT_NAME], |
| 18 | [$class: 'StringParameterValue', name: 'GERRIT_HOST', value: GERRIT_HOST], |
| 19 | [$class: 'StringParameterValue', name: 'GERRIT_PORT', value: GERRIT_PORT], |
| 20 | [$class: 'StringParameterValue', name: 'GERRIT_PROJECT', value: GERRIT_PROJECT], |
| 21 | [$class: 'StringParameterValue', name: 'GERRIT_REFSPEC', value: GERRIT_REFSPEC] |
| 22 | ] |
| 23 | }*/ |
| 24 | } |
| 25 | stage("submit review"){ |
| 26 | ssh.prepareSshAgentKey(CREDENTIALS_ID) |
| 27 | ssh.ensureKnownHosts(GERRIT_HOST) |
| 28 | ssh.agentSh(String.format("ssh -p 29418 %s gerrit review --submit %s,%s", GERRIT_HOST, GERRIT_CHANGE_NUMBER, GERRIT_PATCHSET_NUMBER)) |
| 29 | println(String.format("Gerrit review %s,%s submitted", GERRIT_CHANGE_NUMBER, GERRIT_PATCHSET_NUMBER)) |
| 30 | } catch (Throwable e) { |
| 31 | // If there was an error or exception thrown, the build failed |
| 32 | currentBuild.result = "FAILURE" |
| 33 | throw e |
| 34 | } finally { |
| 35 | common.sendNotification(currentBuild.result,"",["slack"]) |
| 36 | } |
| 37 | } |