Hello Team,
Please suggest me the rule condition for CICD pipeline trigger only though merge request only not through branch updates.
Currently I have applied the below condition…
rules:
if: $CI_PIPELINE_SOURCE == PUSH && $CI_COMMIT_BRANCH == :branch name
: event for pipeline trigger.
I want some additional condition to avoid pipeline trigger through branch file updates.
My expectation: pipeline should trigger only from merge requests not from any event is happening at branch.
Below solutions , i tried for the above case but its not working
- CI_MERGE_REUEST_ predefined parameters.
- only : - merge_requests
Please suggest any solution for the above mentioned issue that is really helping me.
Regards,
Komal
Hi @komalbokariya
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
You can see available values in here
Hello GitLab Team,
This value is getting populated when merge request is open. I want to trigger CICD pipeline when merge event completed.
Please suggest what all parameters i can use in rules condition.
Regards,
Komal
Merging a Merge Request creates a push event to the target branch. There is no difference between branch update commit and Merged MR commit. It is still a commit.
You can try to set your rules around commit message CI_COMMIT_MESSAGE
What specific rule condition can i setup around CI_COMMIT_MESSAGE? . Please suggest some examples that would be helping me.
Example: Agree with your team that each MR commit message must start with ‘MR:’
Setup regex rule - if: '$CI_COMMIT_MESSAGE =~ /^MR:.*/'
that would trigger pipeline if commit message starts with ‘MR:’
Thanks Peter.
I have different query regarding with group level custom project template creation
I am looking to create group level custom project template
This option is not available in my gitlab instance → General settings-> Advanced → custom project templates.
I will achieve this by using python gitlab api https://python-gitlab.readthedocs.io. Please let me know which is relevant API which can be useful to create custom project templates.
HEllo Peter,
AS per your suggestions, i have setup this condition to trigger the job
if: ‘$CI_PIPELINE_SOURCE == “push” && $CI_COMMIT_BRANCH ==:branch_name && $CI_COMMIT_MESSAGE =~ /^MR:.*/’
I have given MR in start when i commit a file in repository & in a title when i creating merge request from source repository to destination repository. Please let me know , am i doing correctly? Where should i give as MR in start so it will populate in a variable $CI_COMMIT_MESSAGE?
I can enter atrt with MR in branch commit as well . how does it differs?