diff mbox series

[RFC,8/9] gitlab-ci: Add rules to skip building cross-jobs

Message ID 20201104224558.3384595-9-philmd@redhat.com
State New
Headers show
Series None | expand

Commit Message

Philippe Mathieu-Daudé Nov. 4, 2020, 10:45 p.m. UTC
Add rules to skip some crossbuild jobs.

The following tags are available to skip CI jobs:
- cross  (skip all cross-jobs)
- system (skip all cross-system jobs)
- user   (skip all cross-user jobs)

Developers can combine tags in the SKIP_BUILD variable when
pushing a branch (or tag) to repositories. Examples:

  $ git push -o ci.variable="SKIP_BUILD=user"        myrepo mybranch
  $ git push -o ci.variable="SKIP_BUILD=user,system" myrepo mybranch

References:
- https://docs.gitlab.com/ee/ci/yaml/#rulesif
- https://docs.gitlab.com/ee/user/project/push_options.html#push-options-for-gitlab-cicd

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 .gitlab-ci.d/crossbuilds.yml | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/.gitlab-ci.d/crossbuilds.yml b/.gitlab-ci.d/crossbuilds.yml
index 701550f028c..08f27649eb2 100644
--- a/.gitlab-ci.d/crossbuilds.yml
+++ b/.gitlab-ci.d/crossbuilds.yml
@@ -1,6 +1,16 @@ 
 .cross_common_job:
   stage: build
   image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:latest
+  rules:
+    # If the if statement is true, the job is excluded from a pipeline.
+    - if: $SKIP_BUILD =~ /cross/
+      when: never
+    - if: $CI_JOB_NAME =~ /system/ && $SKIP_BUILD =~ /system/
+      when: never
+    - if: $CI_JOB_NAME =~ /user/ && $SKIP_BUILD =~ /user/
+      when: never
+    # In all other cases, the job is added to the pipeline.
+    - when: on_success
 
 .cross_system_build_job:
   extends: .cross_common_job