blob: 59d7c6071d2213b1f906b88fdae90443ca677f0c [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-*'"
Tim Windelschmidt6c851e22024-01-11 15:23:48 +010024 sh "JENKINS_NODE_COOKIE=dontKillMe tools/bazel --bazelrc=.bazelrc.ci test //..."
Tim Windelschmidt6c851e22024-01-11 15:23:48 +010025 sh "JENKINS_NODE_COOKIE=dontKillMe tools/bazel --bazelrc=.bazelrc.ci test --config dbg //..."
Tim Windelschmidt3a171d12024-12-09 23:51:23 +010026 sh "JENKINS_NODE_COOKIE=dontKillMe tools/bazel --bazelrc=.bazelrc.ci test --config race //..."
Serge Bazanski6feb7462021-05-18 15:49:15 +020027 }
28 post {
29 success {
30 gerritCheck checks: ['jenkins:test': 'SUCCESSFUL']
31 }
32 unsuccessful {
33 gerritCheck checks: ['jenkins:test': 'FAILED']
34 }
35 }
36 }
37
38 stage('Gazelle') {
39 agent {
40 node {
41 label ""
42 customWorkspace '/home/ci/monogon'
43 }
44 }
45 steps {
46 gerritCheck checks: ['jenkins:gazelle': 'RUNNING'], message: "Running on ${env.NODE_NAME}"
Leopold Schabelda3be1b2021-10-17 22:15:10 +020047 echo "Gerrit change: ${GERRIT_CHANGE_URL}"
Serge Bazanski6feb7462021-05-18 15:49:15 +020048 sh "git clean -fdx -e '/bazel-*'"
Jan Schär5d1bf6a2024-11-12 13:34:40 +010049 sh "JENKINS_NODE_COOKIE=dontKillMe tools/bazel --bazelrc=.bazelrc.ci mod tidy --lockfile_mode=update"
Tim Windelschmidt156248b2025-01-10 00:27:45 +010050 sh "JENKINS_NODE_COOKIE=dontKillMe tools/bazel --bazelrc=.bazelrc.ci run //:tidy"
Serge Bazanski6feb7462021-05-18 15:49:15 +020051 }
52 post {
Jan Schär5d1bf6a2024-11-12 13:34:40 +010053 always {
54 script {
55 def diff = sh script: "git status --porcelain", returnStdout: true
56 if (diff.trim() != "") {
57 sh "git diff HEAD"
58 error """
59 Unclean working directory after running gazelle.
60 Please run:
61
62 \$ bazel mod tidy --lockfile_mode=update
Tim Windelschmidt156248b2025-01-10 00:27:45 +010063 \$ bazel run //:tidy
Jan Schär5d1bf6a2024-11-12 13:34:40 +010064
65 In your git checkout and amend the resulting diff to this changelist.
66 """
67 }
68 }
69 }
Serge Bazanski6feb7462021-05-18 15:49:15 +020070 success {
71 gerritCheck checks: ['jenkins:gazelle': 'SUCCESSFUL']
72 }
73 unsuccessful {
74 gerritCheck checks: ['jenkins:gazelle': 'FAILED']
75 }
76 }
77 }
78 }
Leopold Schabelf1bdfbe2022-05-26 22:43:42 +020079
80 post {
81 success {
82 gerritReview labels: [Verified: 1]
83 }
84 unsuccessful {
85 gerritReview labels: [Verified: -1]
86 }
87 }
Serge Bazanski6feb7462021-05-18 15:49:15 +020088 }
89 }
90}