jenkinsci / gitlab-plugin

A Jenkins plugin for interfacing with GitLab
https://plugins.jenkins.io/gitlab-plugin/
GNU General Public License v2.0
1.44k stars 619 forks source link

#1427: Prevent job triggering for non-matching webhooks #1720

Closed mc1arke closed 2 weeks ago

mc1arke commented 2 weeks ago

8ec69c7ada9da38a760f532b9dd34bdf538f8ccb introduced a change that does not handle jobs created using Jenkins DSL properly, as DSL jobs that do not specify triggerOpenMergeRequestOnPush have the triggerOpenMergeRequest value passed into MergeRequestHookTriggerHandlerFactory as null, with the above change causing the value not to be handled as never where the plugin previously treated null as never. This results in webhooks triggering builds for DSL-created jobs even where the job is doing actions that aren't valid for a Merge Request in that state (e.g. triggering release builds even though the Merge Request hasn't been merged). This change returns to handling an unspecified triggerOpenMergeRequest value as being equivalent to specifying it as never.

Testing done

Automated test to cover failing scenario.

Submitter checklist

krisstern commented 2 weeks ago

Thanks @mc1arke for the PR! I will review it over the next few days

krisstern commented 2 weeks ago

Looks like you may want to run mvn spotless:apply to fix the remaining failed checks

krisstern commented 2 weeks ago

I will cut a release with this code change within the next 24 hours.

krisstern commented 2 weeks ago

New release cut at https://github.com/jenkinsci/gitlab-plugin/releases/tag/gitlab-plugin-1.9.6