Is there a way to skip certain stages based on a pre-merge request and post-merge request (Jenkins/gitlab)

Hi, i am new to jenkins and I am trying to build a CI with Gitlab+Jenkins. what I did so far is this :

I already set the web-hook between Jenkins and GitLab to trigger merge requests and push events.

I just need one last thing that i can’t seem to figure out:

Once the merge request is created(before it is accepted and mereged) and the web-hook is triggered i need some stages to be skipped.

Once the request is accepted and merged and a new build is made, i need some other stages to be skipped.

thanks

You could use when { changeRequest() } on the stages that you want to execute when the pipeline runs for the merge request, and when { not { changeRequest() } } on the stages that you want to execute when the pipeline runs for a branch after the changes have been merged. Pipeline Syntax

The changeRequest() condition checks the CHANGE_ID environment variable, which is added by BranchNameContributor if a multibranch pipeline is running for a change request. You could also make the steps of the stage check CHANGE_ID, instead of using when, but then Jenkins would not be able to display that the stage was skipped.

1 Like

thank you for you interraction … i will try it and see what happens