Hareesh
Hareesh

Reputation: 1

How to write .gitlab-ci.yml job to run only in merge-request is approved

I am checking on a solution where GITLAB CI job has to run only when merge-request is approved.

test_c: stage: test script: - echo "This job tests something. It will only run when all jobs in the" - echo "build stage are complete." rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'

This works when the merge request is created but not when it is approved.

Upvotes: 0

Views: 151

Answers (1)

andy meissner
andy meissner

Reputation: 1322

You could check the predefined variable

CI_MERGE_REQUEST_APPROVED

rules: 
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_APPROVED == "true"

Upvotes: 1

Related Questions