Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 1 | def common = new com.mirantis.mk.Common() |
Filip Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 2 | def ssh = new com.mirantis.mk.Ssh() |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 3 | node() { |
| 4 | try{ |
| 5 | stage("checkout") { |
| 6 | dir("src") { |
Filip Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 7 | ssh.prepareSshAgentKey(CREDENTIALS_ID) |
| 8 | ssh.ensureKnownHosts(SOURCE_URL) |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 9 | git url: SOURCE_URL, branch: "master", credentialsId: CREDENTIALS_ID, poll: false |
| 10 | sh("git branch --set-upstream-to=origin/master") |
Filip Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 11 | ssh.agentSh("make update") |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 12 | } |
| 13 | } |
| 14 | stage("tag") { |
| 15 | dir("src/formulas") { |
| 16 | sh("for i in *; do cd \$i; git remote | grep gerrit || git remote add gerrit $GERRIT_BASE/\$i; git config user.name Jenkins; git config user.email autobuild@mirantis.com; git tag -m $TAG $TAG; cd ..; done") |
| 17 | } |
| 18 | } |
| 19 | stage("push") { |
| 20 | dir("src/formulas") { |
Filip Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 21 | ssh.agentSh("mr --trust-all -j4 --force run git push gerrit $TAG") |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 22 | } |
| 23 | } |
| 24 | } catch (Throwable e) { |
| 25 | // If there was an error or exception thrown, the build failed |
| 26 | currentBuild.result = "FAILURE" |
Jakub Josef | d2efd7d | 2017-08-22 17:49:57 +0200 | [diff] [blame] | 27 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 28 | throw e |
| 29 | } finally { |
| 30 | common.sendNotification(currentBuild.result,"",["slack"]) |
| 31 | } |
Filip Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 32 | } |