blob: 4aaaec90b4fd41e8e6a138fdf7338266bfdf149b [file] [log] [blame]
Jakub Josefc5a223a2017-03-01 14:40:08 +01001def common = new com.mirantis.mk.Common()
Filip Pytloun38005aa2017-03-06 10:26:38 +01002def ssh = new com.mirantis.mk.Ssh()
Jakub Josefc5a223a2017-03-01 14:40:08 +01003node() {
4 try{
5 stage("checkout") {
6 dir("src") {
Filip Pytloun38005aa2017-03-06 10:26:38 +01007 ssh.prepareSshAgentKey(CREDENTIALS_ID)
8 ssh.ensureKnownHosts(SOURCE_URL)
Jakub Josefc5a223a2017-03-01 14:40:08 +01009 git url: SOURCE_URL, branch: "master", credentialsId: CREDENTIALS_ID, poll: false
10 sh("git branch --set-upstream-to=origin/master")
Filip Pytloun38005aa2017-03-06 10:26:38 +010011 ssh.agentSh("make update")
Jakub Josefc5a223a2017-03-01 14:40:08 +010012 }
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 Pytloun38005aa2017-03-06 10:26:38 +010021 ssh.agentSh("mr --trust-all -j4 --force run git push gerrit $TAG")
Jakub Josefc5a223a2017-03-01 14:40:08 +010022 }
23 }
24 } catch (Throwable e) {
25 // If there was an error or exception thrown, the build failed
26 currentBuild.result = "FAILURE"
Jakub Josefd2efd7d2017-08-22 17:49:57 +020027 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
Jakub Josefc5a223a2017-03-01 14:40:08 +010028 throw e
29 } finally {
30 common.sendNotification(currentBuild.result,"",["slack"])
31 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010032}