Useless builds triggered by GitLab merge request hook

Some time ago we migrated from self-hosted Bitbucket to hosted GitLab (gitlab.com). We’ve set up our workflows to build as soon as a PR/MR is created or updated. For Bitbucket this worked as expected, but for GitLab it triggers builds a bit too often.

The problem seems to be that GitLab’s Merge Request Hook is being triggered for any change in an MR, including changing the title or the assignee. We’d like it to only trigger when the MR is created or new commits are pushed to its source branch, just like we had with Bitbucket.
For now we’ve already stopped assigning MRs to people, but we still get a lot of useless builds for commits that have already been built before, because of MR state changes.

I’ve read some other CI systems have had similar issues, and solved them by filtering incoming GitLab webhooks on a combination of action and some other fields. The action field in the posted JSON will contain “open” for new MRs and “update” for any updates. I think the oldrev field is only available when there were new commits, so maybe that’s something you could filter on?

If there’s any other way we can work around this problem, please let me know. We’ve thought about disabling PR triggers and only relying on push triggers, but that will also give us a lot of builds I’m afraid, and we’ll lose the connection between builds and MRs.

Hi, thanks for the report, your request sounds fair, i created a card to solve this.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.