Skip to content

Commit 868b6b6

Browse files
andrei-pavelwwencel
authored andcommitted
[#3669] Prevent duplicate pipelines in CI
1 parent 5d36a43 commit 868b6b6

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

.gitlab-ci.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@ stages:
2525
- test
2626
- fuzz
2727

28-
# Do not run the test stage on pipeline schedule trigger.
2928
.base_rules_for_test_jobs: &rules_for_test_stage
3029
rules:
31-
- if: $CI_PIPELINE_SOURCE != 'schedule'
32-
when: always
30+
# Do not run the test stage on pipeline schedule trigger.
3331
- if: $CI_PIPELINE_SOURCE == 'schedule'
3432
when: never
33+
# Prevent duplicate pipelines.
34+
- if: $CI_OPEN_MERGE_REQUESTS && $CI_COMMIT_BRANCH == null
35+
when: never
36+
# On any other event, including push to MR branch and push to master.
37+
- when: always
3538

3639
are-database-scripts-in-sync:
3740
stage: test
@@ -155,15 +158,17 @@ fuzz:
155158
matrix:
156159
- SANITIZER: [address, undefined]
157160
rules:
161+
# Prevent duplicate pipelines.
162+
- if: $CI_OPEN_MERGE_REQUESTS && $CI_COMMIT_BRANCH == null
163+
when: never
158164
# On merge request.
159-
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
165+
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
160166
variables:
161167
MODE: "code-change"
162168
when: manual
163169
allow_failure: true
164-
# And on push to master.
165-
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
166-
when: always
170+
# Run on any other event, including push to MR branch and push to master.
171+
- when: always
167172
before_script:
168173
# Get GitLab's container id.
169174
- export CFL_CONTAINER_ID=`docker ps -q -f "label=com.gitlab.gitlab-runner.job.id=$CI_JOB_ID" -f "label=com.gitlab.gitlab-runner.type=build"`
@@ -313,6 +318,10 @@ flawfinder-sast:
313318
when: never
314319
- if: $SAST_EXCLUDED_ANALYZERS =~ /flawfinder/
315320
when: never
321+
# Prevent duplicate pipelines.
322+
- if: $CI_OPEN_MERGE_REQUESTS && $CI_COMMIT_BRANCH == null
323+
when: never
324+
# Run on any other event, including push to master.
316325
- when: always
317326

318327
semgrep-sast:
@@ -322,6 +331,8 @@ semgrep-sast:
322331
when: never
323332
- if: $CI_PIPELINE_SOURCE == 'schedule'
324333
when: never
325-
- if: $SAST_EXCLUDED_ANALYZERS =~ /semgrep/
334+
# Prevent duplicate pipelines.
335+
- if: $CI_OPEN_MERGE_REQUESTS && $CI_COMMIT_BRANCH == null
326336
when: never
337+
# Run on any other event, including push to MR branch and push to master.
327338
- when: always

0 commit comments

Comments
 (0)