blob: 75c057517f255e1206b7187e46491c4a02f76ef5 [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}"
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}