0

How do we trigger a pipeline in gitlab once the PR is merged and approved. Below is my code:

contactcreate-tst2-19:
  stage: deploy
  script:
    - 'curl --request POST --form token=<token> --form ref=19.0 --form variables[ENVIRONMENT]=TST2 https://vcs.build.livevox.net/api/v4/<id>/trigger/pipeline'
  rules:
    - if: $CI_MERGE_REQUEST_APPROVED
      changes:
        - 'contact/contact-create/TST2/config.json'

anothe rule for below comment question

rules:
    - if: $CI_MERGE_REQUEST_APPROVED
      changes:
        - 'scripter/TST2/scripterTestData.json'
        - 'scripter/.gitlab-scripter.yml'
      when: manual
Shreyas Murali
  • 329
  • 1
  • 2
  • 17
  • So you don't want it to run if the merge request was only merged, but not approved? Could you clarify your requirements and what hasn't worked for you so far? – D Malan Jan 08 '23 at 14:03
  • We want to trigger a pipeline once the created PR is approved and merged. I have used other rule updated above in the question. The pipeline still trigger in blocked stated if I use manual. I need to know how to trigger once approved and merged so that pipeline triggers. – Shreyas Murali Jan 12 '23 at 10:03
  • Do you only care about merges to a specific branch, e.g. `main`? If yes, then you could rather trigger the pipeline on commits to `main`, e.g. `only: - main`. That way, the pipeline will run once a PR has been merged to `main`. I don't think there are specific settings to check only for merges as opposed to commits. – D Malan Jan 12 '23 at 10:09

0 Answers0