Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger build when merge request has been merged #390

Closed
klausbayrhammer opened this issue Aug 11, 2016 · 13 comments
Closed

Trigger build when merge request has been merged #390

klausbayrhammer opened this issue Aug 11, 2016 · 13 comments
Assignees

Comments

@klausbayrhammer
Copy link

Is it possible to trigger a build if a merge request has been merged? Although the gitlab webhook description says the "Trigger when merge request is merged" but no build is triggered.

Is there any way to configure a job/gitlab to achieve that?

@dblessing
Copy link

What is the use-case for running a build after a MR is accepted?

@dennyferra
Copy link

Was coming here to ask about this. My particular use-case is I want to automate clean up of deployed feature branches after a merge request has been merged.

Since I didn't see an explicit trigger for "merged" I thought perhaps it would come through under the gitlabActionType as "MERGED" - but that doesn't appear to be the case. This is also assuming that gitlabSourceBranch is sent down so I can determine the correct feature to clean up.

@omehegan
Copy link
Member

According to the current GitLab doc, the MR web hook should be, "Triggered when a new merge request is created, an existing merge request was updated/merged/closed or a commit is added in the source branch." So it would seem like if you have an MR webhook triggering your Jenkins job, the job should run when an MR is merged or closed. It could be that the plugin ignores those events because in theory it would already have built them.

@dennyferra isn't there an option in GitLab to remove a branch after it is merged?

@dennyferra
Copy link

@omehegan

Yes that option does exist, however I wanted to run a script to clean up our feature branch environment as well (not just the branch). Perhaps I can do this with a git hook.

@omehegan
Copy link
Member

@coder-hugo can you comment on whether the plugin ignores 'MR close' events? I can imagine that it might...

@omehegan
Copy link
Member

omehegan commented Jan 4, 2017

I have confirmed that we ignore MR close events. Reference the code here.

I think that we would want to add an option to support triggering on MR close, so it's not always enabled, so this would require more than just a one-line change. I will mark it as a feature request if someone wants to implement it.

@mreichel
Copy link
Contributor

@omehegan Ok, there is already a merge request out there. What's the state with the reviews? I could review it otherwise

@omehegan
Copy link
Member

@mreichel if you want to review that PR, that would be great :)

@adityosnrost
Copy link

Hi,

I would like to know how to configure this on my Jenkins ? I am also need to build after the merge request is accepted. I am new with Jenkins things. It would be great to know about how to do it step by step.

Thanks

@mreichel
Copy link
Contributor

@adityosnrost the current version of the plugin can trigger a build, after a merge request is accepted/merged because a push event will happen. If that's what you want, you can take a look at the Readme file, where the configuration is explained in detail and hopefully serves well as a step by step introduction.

The new feature described in this thread is not yet released. To use it now, you would need to build the plugin from source.

@adityosnrost
Copy link

Hello,

@mreichel Thanks for your reply. So, basically for this version, I just listen to push event on the targeted merge branch, right ?

@mreichel
Copy link
Contributor

@adityosnrost Yes, that should work. The build will be triggered once the pull requests is merged/pushed onto the target branch.

@dracorp
Copy link

dracorp commented Dec 7, 2021

Hi. Is there any example how to trigger on merged/closed hook? For me it does not work. It is invoked push webhook instead.

exceed-alae pushed a commit to exceed-alae/gitlab-plugin that referenced this issue May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants