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

Build only for merge requests, not for regular pushes #49

Closed
Yogu opened this issue Feb 2, 2015 · 9 comments
Closed

Build only for merge requests, not for regular pushes #49

Yogu opened this issue Feb 2, 2015 · 9 comments

Comments

@Yogu
Copy link

Yogu commented Feb 2, 2015

We have two jobs on our servers:

  • a normal job that builds master, so we always see if the main branch passes the build and have a nice history of code metrics
  • the merge-request job, configured as instructed in this README, to get build information in the merge requests

Currently, the merge-request job also builds the branches on normal pushes, so on every push to master, two builds are scheduled. We'd like the merge-request job to only build when pushing to a branch with an open merge request, i.e. iff the build comment will be of the form "GitLab ​Merge ​​Request ​​#xx ​​: source-branch ​​=> ​​master ".

Is this possible? If I disable "Build on Push Events", subsequent pushes to open merge requests are not built. The "Filter branches" box also looks promising, we could simply exclude master, but the list is empty for me, even after a few builds.

@kasper-f
Copy link
Contributor

kasper-f commented Feb 3, 2015

I haven't been able to reproduce the issue with duplicate builds on push.

I have test with

  • uncheck the config box "Build on Merge Request Events" (all other checked) and the push to a branch with an open merge request. It did not trigger a new build.
  • uncheck the config box "Build on Push Events" (all other checked) and push to master branch. It did not trigger a new build.

In my config I have selected to only build the "master" branch in the "Filter branches" option. I don't know why you don't get a list of branches in the filter branch config option. Have you tried to look at Jenkins log file to see if it give you any hints regarding the missing branches?

@MartinNowak
Copy link
Contributor

It works as supposed out of the box, just disable the build on push.
Your problem might be a missing global gitlab configuration b/c the webhook needs to query gitlab's api in order to get the list of open merge requests. Just check the jenkins 'system log' and/or add the gitlab api token in 'configure system'.

@WonderCsabo
Copy link
Contributor

I also have this problem. I would not like to disable build on push because i want to build all branches, but if a branch is on a merge request, do not duplicate the build (just build the MR event instead).

@sbamani
Copy link

sbamani commented Jan 22, 2016

I have a similar problem - even when I uncheck the "Build when changes are pushed to gitlab" it is still building on every push... I tried checking it and the uncheck the "Build on Merge Request Events" and the "Build on Push Events" But it still trigger a build.

@coder-hugo
Copy link
Contributor

Duplicate of #210

@starthal
Copy link

starthal commented Jan 11, 2018

Is the behavior described here still expected/intended?

When MR trigger and push trigger are both enabled, a push to an open MR should trigger two builds (one merged, one not merged)?

This "duplication" of the builds doesn't bother me, but they both seem to update the MR pipeline status in GitLab, so there is a race condition when the builds are run in parallel. If one fails and the other succeeds, the result is confusing.

@omehegan
Copy link
Member

@starthal yes I think it is expected. IIRC they are technically two different commits so the plugin doesn't have any way to discern that they are or could be the same effective state of the repo.

@starthal
Copy link

@omehegan Thanks. Is there a way to prevent the non-merged build from updating the MR status in GitLab? Or to give different "build names" to the merged and non-merged builds so GitLab treats them as separate "pipelines"?

By "build name" I mean this field:

2018-01-15-084746_580x164_scrot

@omehegan
Copy link
Member

@starthal if it was a Pipeline job, you could use some logic to look at the gitlabActionType env var and only update status for one or the other type.

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

No branches or pull requests

8 participants