blob: 5bb148bad15e32e21382239d472827ddfe59ab37 [file] [log] [blame]
Serge Bazanski6feb7462021-05-18 15:49:15 +02001// 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
5pipeline {
6 agent none
Serge Bazanski3bb23212021-08-24 16:27:21 +02007 options {
8 disableConcurrentBuilds()
9 }
Serge Bazanski6feb7462021-05-18 15:49:15 +020010 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}"
Leopold Schabelda3be1b2021-10-17 22:15:10 +020022 echo "Gerrit change: ${GERRIT_CHANGE_URL}"
Serge Bazanski6feb7462021-05-18 15:49:15 +020023 sh "git clean -fdx -e '/bazel-*'"
Serge Bazanskibf599452021-10-06 00:00:22 +020024 sh "JENKINS_NODE_COOKIE=dontKillMe bazel test //..."
25 sh "JENKINS_NODE_COOKIE=dontKillMe bazel test -c dbg //..."
Serge Bazanski6feb7462021-05-18 15:49:15 +020026 }
27 post {
28 success {
29 gerritCheck checks: ['jenkins:test': 'SUCCESSFUL']
30 }
31 unsuccessful {
32 gerritCheck checks: ['jenkins:test': 'FAILED']
33 }
34 }
35 }
36
37 stage('Gazelle') {
38 agent {
39 node {
40 label ""
41 customWorkspace '/home/ci/monogon'
42 }
43 }
44 steps {
45 gerritCheck checks: ['jenkins:gazelle': 'RUNNING'], message: "Running on ${env.NODE_NAME}"
Leopold Schabelda3be1b2021-10-17 22:15:10 +020046 echo "Gerrit change: ${GERRIT_CHANGE_URL}"
Serge Bazanski6feb7462021-05-18 15:49:15 +020047 sh "git clean -fdx -e '/bazel-*'"
Serge Bazanskibf599452021-10-06 00:00:22 +020048 sh "JENKINS_NODE_COOKIE=dontKillMe bazel run //:fietsje"
49 sh "JENKINS_NODE_COOKIE=dontKillMe bazel run //:gazelle -- update"
Serge Bazanski6feb7462021-05-18 15:49:15 +020050
51 script {
52 def diff = sh script: "git status --porcelain", returnStdout: true
53 if (diff.trim() != "") {
54 sh "git diff HEAD"
55 error """
56 Unclean working directory after running gazelle and Fietsje.
57 Please run:
58
59 \$ bazel run //:fietsje
60 \$ bazel run //:gazelle -- update
61
62 In your git checkout and amend the resulting diff to this changelist.
63 """
64 }
65 }
66 }
67 post {
68 success {
69 gerritCheck checks: ['jenkins:gazelle': 'SUCCESSFUL']
70 }
71 unsuccessful {
72 gerritCheck checks: ['jenkins:gazelle': 'FAILED']
73 }
74 }
75 }
76 }
77 }
78 }
79}