Jakub Josef | 8337931 | 2017-03-29 18:12:34 +0200 | [diff] [blame] | 1 | /** |
| 2 | * Test salt formulas pipeline |
| 3 | * DEFAULT_GIT_REF |
| 4 | * DEFAULT_GIT_URL |
| 5 | * CREDENTIALS_ID |
| 6 | */ |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 7 | def common = new com.mirantis.mk.Common() |
| 8 | def gerrit = new com.mirantis.mk.Gerrit() |
Jakub Josef | 8337931 | 2017-03-29 18:12:34 +0200 | [diff] [blame] | 9 | |
| 10 | def gerritRef |
| 11 | try { |
| 12 | gerritRef = GERRIT_REFSPEC |
| 13 | } catch (MissingPropertyException e) { |
| 14 | gerritRef = null |
| 15 | } |
| 16 | |
| 17 | def defaultGitRef, defaultGitUrl |
| 18 | try { |
| 19 | defaultGitRef = DEFAULT_GIT_REF |
| 20 | defaultGitUrl = DEFAULT_GIT_URL |
| 21 | } catch (MissingPropertyException e) { |
| 22 | defaultGitRef = null |
| 23 | defaultGitUrl = null |
| 24 | } |
| 25 | |
| 26 | def checkouted = false; |
| 27 | |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 28 | node("python") { |
| 29 | try{ |
| 30 | stage("checkout") { |
Jakub Josef | 8337931 | 2017-03-29 18:12:34 +0200 | [diff] [blame] | 31 | if (gerritRef) { |
| 32 | // job is triggered by Gerrit |
| 33 | checkouted = gerrit.gerritPatchsetCheckout ([ |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 34 | credentialsId : CREDENTIALS_ID |
Jakub Josef | 8337931 | 2017-03-29 18:12:34 +0200 | [diff] [blame] | 35 | ]) |
| 36 | } else if(defaultGitRef && defaultGitUrl) { |
Jakub Josef | e1407ac | 2017-03-30 14:10:19 +0200 | [diff] [blame] | 37 | checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "HEAD", CREDENTIALS_ID) |
Jakub Josef | 8337931 | 2017-03-29 18:12:34 +0200 | [diff] [blame] | 38 | } |
| 39 | if(!checkouted){ |
Jakub Josef | 5ce6a36 | 2017-03-31 13:41:17 +0200 | [diff] [blame] | 40 | throw new Exception("Cannot checkout gerrit patchset, GERRIT_REFSPEC and DEFAULT_GIT_REF is null") |
Jakub Josef | 8337931 | 2017-03-29 18:12:34 +0200 | [diff] [blame] | 41 | } |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 42 | } |
| 43 | stage("test") { |
Jakub Josef | 8337931 | 2017-03-29 18:12:34 +0200 | [diff] [blame] | 44 | if(checkouted){ |
| 45 | wrap([$class: 'AnsiColorBuildWrapper']) { |
| 46 | sh("make clean") |
| 47 | sh("[ $SALT_VERSION != 'latest' ] || export SALT_VERSION=''; make test") |
| 48 | } |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 49 | } |
| 50 | } |
| 51 | } catch (Throwable e) { |
| 52 | // If there was an error or exception thrown, the build failed |
| 53 | currentBuild.result = "FAILURE" |
| 54 | throw e |
| 55 | } finally { |
| 56 | common.sendNotification(currentBuild.result,"",["slack"]) |
| 57 | } |
| 58 | } |