Browse code

Jenkinsfile: force validate steps on master and backports

On master ("non-pull-request"), force running some validation checks
(such as vendor, swagger), even if no files were changed. This allows
catching problems caused by pull-requests that were merged out-of-sequence.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2019/10/07 19:23:19
Showing 1 changed files
... ...
@@ -9,6 +9,7 @@ pipeline {
9 9
     }
10 10
     parameters {
11 11
         booleanParam(name: 'unit_validate', defaultValue: true, description: 'amd64 (x86_64) unit tests and vendor check')
12
+        booleanParam(name: 'validate_force', defaultValue: false, description: 'force validation steps to be run, even if no changes were detected')
12 13
         booleanParam(name: 'amd64', defaultValue: true, description: 'amd64 (x86_64) Build/Test')
13 14
         booleanParam(name: 'arm64', defaultValue: true, description: 'ARM (arm64) Build/Test')
14 15
         booleanParam(name: 's390x', defaultValue: true, description: 'IBM Z (s390x) Build/Test')
... ...
@@ -62,6 +63,12 @@ pipeline {
62 62
                         expression { params.unit_validate }
63 63
                     }
64 64
                     agent { label 'amd64 && ubuntu-1804 && overlay2' }
65
+                    environment {
66
+                        // On master ("non-pull-request"), force running some validation checks (vendor, swagger),
67
+                        // even if no files were changed. This allows catching problems caused by pull-requests
68
+                        // that were merged out-of-sequence.
69
+                        TEST_FORCE_VALIDATE = sh returnStdout: true, script: 'if [ "${BRANCH_NAME%%-*}" != "PR" ] || [ "${CHANGE_TARGET:-master}" != "master" ] || [ "${validate_force}" = "true" ]; then echo "1"; fi'
70
+                    }
65 71
 
66 72
                     stages {
67 73
                         stage("Print info") {
... ...
@@ -90,6 +97,7 @@ pipeline {
90 90
                                   -e DOCKER_EXPERIMENTAL \
91 91
                                   -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
92 92
                                   -e DOCKER_GRAPHDRIVER \
93
+                                  -e TEST_FORCE_VALIDATE \
93 94
                                   -e VALIDATE_REPO=${GIT_URL} \
94 95
                                   -e VALIDATE_BRANCH=${CHANGE_TARGET} \
95 96
                                   docker:${GIT_COMMIT} \
... ...
@@ -197,6 +205,7 @@ pipeline {
197 197
                                   -e DOCKER_EXPERIMENTAL \
198 198
                                   -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
199 199
                                   -e DOCKER_GRAPHDRIVER \
200
+                                  -e TEST_FORCE_VALIDATE \
200 201
                                   -e VALIDATE_REPO=${GIT_URL} \
201 202
                                   -e VALIDATE_BRANCH=${CHANGE_TARGET} \
202 203
                                   docker:${GIT_COMMIT} \