How can I skip deployment job after merging a merge request which has a label?

  Kiến thức lập trình

Suppose I have the below job rule that triggers the deployment job after a merge request is merged into the main branch

deploy_job:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME == "main"'

There is a requirement to avoid running the deployment job if a merge request contains the label skip-deploy-job.
I tried changing the rule by checking the variable $CI_MERGE_REQUEST_LABELS as below:

deploy_job:
  rules:
    - if: $CI_MERGE_REQUEST_LABELS !~ /skip-deploy-job/ && '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME == "main"'

But unfortunately $CI_MERGE_REQUEST_LABELS is empty in this context, and the above condition evaluates to True. Could you suggest any other way to fulfill this requirement?

1

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT