jenkinsci / jenkinsci/gitlab-plugin
If the setting "Do not allow concurrent builds" in Jenkins is on, and one job batches more then one merge request, all of the GitLabWebHookCause points to the initial trigger.
- Dominant language
- Java
- Stars
- 1.4k
- Forks
- 615
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 10
Description
### Jenkins and plugins versions report
If the setting `"Do not allow concurrent builds"` in Jenkins is on, and one job batches more then one merge request, all of the GitLabWebHookCause points to the initial trigger.
If you would check `currentBuild.rawBuild.causes` and Jenkins job batches multiple merge requests into one - each of the `currentBuild.rawBuild.causes` that are `instanceof com.dabsquared.gitlabjenkins.cause.GitLabWebHookCause` have the same values (not sure about reference)
Jenkinsfile groovy
```.groovy
currentBuild.rawBuild.causes
.findAll { cause -> cause instanceof com.dabsquared.gitlabjenkins.cause.GitLabWebHookCause }
.each { cause ->
echo "Found GitlabMergeRequestCause: ${cause.data}"
}
```
Both of these also point to the rage of the first trigger.
```.groovy
echo "gitlabBefore: ${env.gitlabBefore}"
echo "gitlabAfter: ${env.gitlabAfter}"
```
Settings:
* Do not allow concurrent builds
* Build when a change is pushed to GitLab
* Push Events
* and a groovy script from gitlab
### What Operating System are you using (both controller, and any agents involved in the problem)?
alpine linux containers
### Reproduction steps
1. Create a gitlab repo
2. add a jenkins pipeline webhook
3. configure with the settings from above
4. configure pipeline so that it builds for 5-10 minute to allow batching multiple merge requests
5. merge a merge_request_1 (it should start building)
6. when merge_request_1 is merged and job is triggered merge merge_request_2 and merge_request_3
7. with the setting `"Do not allow concurrent builds"` merge_request_2 should be a job trigger and merged merge_request_3 should be added to the `currentBuild.rawBuild.causes`
### Expected Results
1. All of the `rawBuild.causes` are different and correct
### Actual Results
1. All of the `rawBuild.causes` are different are the same (either by value or by reference, not sure if groovy can do deep references, so probably just the same value gets assigned to the build cause)
### Anything else?
_No response_
### Are you interested in contributing a fix?
Yes.
Contributor guide
Assessment
This issue has not been assessed yet.