Serge Bazanski | 6feb746 | 2021-05-18 15:49:15 +0200 | [diff] [blame] | 1 | // This is a 'Jenkinsfile'-style declarative 'Pipeline' definition. It is |
| 2 | // executed by Jenkins for presubmit checks, ie. checks that run against an |
| 3 | // open Gerrit change request. |
| 4 | |
| 5 | pipeline { |
| 6 | agent none |
Serge Bazanski | 3bb2321 | 2021-08-24 16:27:21 +0200 | [diff] [blame] | 7 | options { |
| 8 | disableConcurrentBuilds() |
| 9 | } |
Serge Bazanski | 6feb746 | 2021-05-18 15:49:15 +0200 | [diff] [blame] | 10 | stages { |
| 11 | stage('Parallel') { |
| 12 | parallel { |
| 13 | stage('Test') { |
| 14 | agent { |
| 15 | node { |
| 16 | label "" |
| 17 | customWorkspace '/home/ci/monogon' |
| 18 | } |
| 19 | } |
| 20 | steps { |
| 21 | gerritCheck checks: ['jenkins:test': 'RUNNING'], message: "Running on ${env.NODE_NAME}" |
| 22 | sh "git clean -fdx -e '/bazel-*'" |
| 23 | sh "bazel test //..." |
| 24 | sh "bazel test -c dbg //..." |
| 25 | } |
| 26 | post { |
| 27 | success { |
| 28 | gerritCheck checks: ['jenkins:test': 'SUCCESSFUL'] |
| 29 | } |
| 30 | unsuccessful { |
| 31 | gerritCheck checks: ['jenkins:test': 'FAILED'] |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | stage('Gazelle') { |
| 37 | agent { |
| 38 | node { |
| 39 | label "" |
| 40 | customWorkspace '/home/ci/monogon' |
| 41 | } |
| 42 | } |
| 43 | steps { |
| 44 | gerritCheck checks: ['jenkins:gazelle': 'RUNNING'], message: "Running on ${env.NODE_NAME}" |
| 45 | sh "git clean -fdx -e '/bazel-*'" |
| 46 | sh "bazel run //:fietsje" |
| 47 | sh "bazel run //:gazelle -- update" |
| 48 | |
| 49 | script { |
| 50 | def diff = sh script: "git status --porcelain", returnStdout: true |
| 51 | if (diff.trim() != "") { |
| 52 | sh "git diff HEAD" |
| 53 | error """ |
| 54 | Unclean working directory after running gazelle and Fietsje. |
| 55 | Please run: |
| 56 | |
| 57 | \$ bazel run //:fietsje |
| 58 | \$ bazel run //:gazelle -- update |
| 59 | |
| 60 | In your git checkout and amend the resulting diff to this changelist. |
| 61 | """ |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | post { |
| 66 | success { |
| 67 | gerritCheck checks: ['jenkins:gazelle': 'SUCCESSFUL'] |
| 68 | } |
| 69 | unsuccessful { |
| 70 | gerritCheck checks: ['jenkins:gazelle': 'FAILED'] |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | } |