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 613 forks source link

Webhook trigger handler does not process new commit trigger on open merge requests: GitLab plugin 1.8.0 #1637

Closed catyjane closed 7 months ago

catyjane commented 7 months ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.440.1 OS: Linux - 4.18.0-477.21.1.el8_8.x86_64 Java: 11.0.20 - Red Hat, Inc. (OpenJDK 64-Bit Server VM) --- Parameterized-Remote-Trigger:3.2.0 ace-editor:1.1 analysis-model-api:12.1.0 ant:497.v94e7d9fffa_b_9 antisamy-markup-formatter:162.v0e6ec0fcfcf6 apache-httpcomponents-client-4-api:4.5.14-208.v438351942757 artifactory:4.0.5 authentication-tokens:1.53.v1c90fd9191a_b_ badge:1.9.1 bootstrap4-api:4.6.0-6 bootstrap5-api:5.3.2-4 bouncycastle-api:2.30.1.77-225.v26ea_c9455fd9 branch-api:2.1152.v6f101e97dd77 build-environment:1.7 build-failure-analyzer:2.5.0 build-name-setter:2.4.1 build-timeout:1.32 build-token-root:151.va_e52fe3215fc caffeine-api:3.1.8-133.v17b_1ff2e0599 checks-api:2.0.2 cloudbees-disk-usage-simple:203.v3f46a_7462b_1a_ cloudbees-folder:6.901.vb_4c7a_da_75da_3 command-launcher:107.v773860566e2e commons-lang3-api:3.13.0-62.v7d18e55f51e2 commons-text-api:1.11.0-95.v22a_d30ee5d36 conditional-buildstep:1.4.3 config-file-provider:968.ve1ca_eb_913f8c copyartifact:722.v0662a_9b_e22a_c credentials:1319.v7eb_51b_3a_c97b_ credentials-binding:657.v2b_19db_7d6e6d cygpath:1.5 cygwin-process-killer:0.2 data-tables-api:1.13.8-4 description-setter:239.vd0a_6b_785f92d display-url-api:2.200.vb_9327d658781 docker-commons:439.va_3cb_0a_6a_fb_29 docker-workflow:572.v950f58993843 dtkit-api:3.0.2 durable-task:550.v0930093c4b_a_6 echarts-api:5.4.3-4 email-ext:2.104 envinject:2.908.v66a_774b_31d93 envinject-api:1.199.v3ce31253ed13 extended-choice-parameter:376.v2e02857547b_a_ extended-read-permission:53.v6499940139e5 font-awesome-api:6.5.1-3 forensics-api:2.4.0 git:5.2.1 git-client:4.6.0 git-server:114.v068a_c7cc2574 github-api:1.318-461.v7a_c09c9fa_d63 gitlab-plugin:1.8.0 gradle:2.10 greenballs:1.15.1 groovy:457.v99900cb_85593 gson-api:2.10.1-15.v0d99f670e0a_7 handlebars:3.0.8 htmlpublisher:1.32 instance-identity:185.v303dc7c645f9 ionicons-api:56.v1b_1c8c49374e ivy:2.5 jackson2-api:2.16.1-373.ve709c6871598 jakarta-activation-api:2.0.1-3 jakarta-mail-api:2.0.1-3 javadoc:243.vb_b_503b_b_45537 javax-activation-api:1.2.0-6 javax-mail-api:1.6.2-9 jaxb:2.3.9-1 jdk-tool:73.vddf737284550 jersey2-api:2.41-133.va_03323b_a_1396 jfrog:1.5.0 jira-steps:2.0.165.v8846cf59f3db jjwt-api:0.11.5-77.v646c772fddb_0 jobConfigHistory:1229.v3039470161a_d joda-time-api:2.12.7-29.v5a_b_e3a_82269a_ jquery3-api:3.7.1-2 jsch:0.2.16-86.v42e010d9484b_ json-api:20240205-27.va_007549e895c json-path-api:2.9.0-33.v2527142f2e1d junit:1259.v65ffcef24a_88 klocwork:2023.3.1 kubernetes:4186.v1d804571d5d4 kubernetes-client-api:6.10.0-240.v57880ce8b_0b_2 kubernetes-credentials:0.11 last-changes:2.7.11 ldap:711.vb_d1a_491714dc lockable-resources:1243.v346d600eea_24 log-parser:2.3.3 mailer:463.vedf8358e006b_ mapdb-api:1.0.9-28.vf251ce40855d matrix-auth:3.2.1 matrix-project:822.824.v14451b_c0fd42 maven-plugin:3.23 metrics:4.2.21-449.v6960d7c54c69 mina-sshd-api-common:2.12.0-90.v9f7fb_9fa_3d3b_ mina-sshd-api-core:2.12.0-90.v9f7fb_9fa_3d3b_ momentjs:1.1.1 monitoring:1.98.0 next-build-number:1.8 okhttp-api:4.11.0-172.vda_da_1feeb_c6e pam-auth:1.10 parameter-separator:166.vd0120849b_386 parameterized-trigger:787.v665fcf2a_830b_ pipeline-build-step:540.vb_e8849e1a_b_d8 pipeline-graph-analysis:216.vfd8b_ece330ca_ pipeline-graph-view:224.vef989d141666 pipeline-groovy-lib:704.vc58b_8890a_384 pipeline-input-step:491.vb_07d21da_1a_fb_ pipeline-milestone-step:111.v449306f708b_7 pipeline-model-api:2.2175.v76a_fff0a_2618 pipeline-model-definition:2.2175.v76a_fff0a_2618 pipeline-model-extensions:2.2175.v76a_fff0a_2618 pipeline-rest-api:2.34 pipeline-stage-step:305.ve96d0205c1c6 pipeline-stage-tags-metadata:2.2175.v76a_fff0a_2618 pipeline-stage-view:2.34 pipeline-utility-steps:2.16.2 plain-credentials:143.v1b_df8b_d3b_e48 plot:2.1.12 plugin-util-api:4.1.0 popper-api:1.16.1-3 popper2-api:2.11.6-4 prism-api:1.29.0-13 prometheus:2.5.1 pyenv-pipeline:2.1.2 rebuild:330.v645b_7df10e2a_ resource-disposer:0.23 role-strategy:689.v731678c3e0eb_ run-condition:1.7 scm-api:683.vb_16722fb_b_80b_ script-security:1326.vdb_c154de8669 shiningpanda:0.24 show-build-parameters:1.0 sidebar-link:2.4.1 slack:684.v833089650554 snakeyaml-api:2.2-111.vc6598e30cc65 ssh-agent:346.vda_a_c4f2c8e50 ssh-credentials:308.ve4497b_ccd8f4 ssh-slaves:2.948.vb_8050d697fec sshd:3.322.v159e91f6a_550 structs:337.v1b_04ea_4df7c8 subversion:2.17.3 timestamper:1.26 token-macro:400.v35420b_922dcb_ trilead-api:2.133.vfb_8a_7b_9c5dd1 uno-choice:2.8.1 variant:60.v7290fc0eb_b_cd warnings-ng:11.1.0 windows-slaves:1.8.1 workflow-aggregator:596.v8c21c963d92d workflow-api:1291.v51fd2a_625da_7 workflow-basic-steps:1042.ve7b_140c4a_e0c workflow-cps:3880.vb_ef4b_5cfd270 workflow-cps-global-lib:612.v55f2f80781ef workflow-durable-task-step:1331.vc8c2fed35334 workflow-job:1400.v7fd111b_ec82f workflow-multibranch:773.vc4fe1378f1d5 workflow-scm-step:415.v434365564324 workflow-step-api:657.v03b_e8115821b_ workflow-support:865.v43e78cc44e0d ws-cleanup:0.45 xunit:3.1.4 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Alma LInux 8.8 controller Discovered after upgrading Jenkins from 2.375.1 to 2.440.1 and GitLab plugin from 1.6.0 to 1.8.0

Reproduction steps

Push a new commit to a branch with an open merge request

Expected Results

Trigger a new build of the CI test job

Example from working trigger log (pre-upgrade): `Feb 29, 2024 2:36:48 AM INFO com.dabsquared.gitlabjenkins.webhook.GitLabWebHook getDynamic WebHook called with url: /project//check_build Feb 29, 2024 2:36:48 AM FINE com.dabsquared.gitlabjenkins.webhook.build.MergeRequestBuildAction MergeRequest: { "object_kind" : "merge_request", "event_type" : "merge_request", "user" : { "id" : xxx, "name" : "xxx", "username" : "xxx", "avatar_url" : "xxx", "email" : "[REDACTED]" },

.......

"assignees" : [ { "id" : 378, "name" : "xxx", "username" : "xxx", "avatar_url" : "xxx", "email" : "[REDACTED]" } ] } Feb 29, 2024 2:36:48 AM FINEST com.dabsquared.gitlabjenkins.trigger.handler.merge.MergeRequestHookTriggerHandlerImpl Skipping LastCommitNotYetBuild check for open action Feb 29, 2024 2:36:48 AM INFO com.dabsquared.gitlabjenkins.trigger.handler.AbstractWebHookTriggerHandler handle

/check_build triggered for merge request.` ### Actual Results No new build is triggered Log output (after upgrade): `Feb 29, 2024 9:07:25 AM INFO com.dabsquared.gitlabjenkins.webhook.GitLabWebHook getDynamic WebHook called with url: /project/ckratzmann//check_build_sandbox Feb 29, 2024 9:07:25 AM FINE com.dabsquared.gitlabjenkins.webhook.build.MergeRequestBuildAction MergeRequest: { "object_kind" : "merge_request", "event_type" : "merge_request", "user" : { "id" : 786, "name" : "xxx", "username" : "xxx", "avatar_url" : "xxx", "email" : "[REDACTED]" }, .......... "repository" : { "name" : "", "url" : "git@internal-gitlab/.git", "description" : "xxx", "homepage" : "http://internal-gitlab/" } }` ^^^ this isn't truncated, that's the end of the log output, no output from abstract handler ### Anything else? The job is successfully triggered on new merge request creation and note actions, just not new commits. ### Are you interested in contributing a fix? _No response_
catyjane commented 7 months ago

Of course I find this immediately after opening the ticket; looks like this was caused by a previous bug that was fixed. When you first create a job with the "Build when a change is pushed to GitLab" trigger, the default value for "Rebuild open Merge Requests" is set to Never. This did not work as expected and our jobs would be triggered on new commits as desired, so I just left it as-is. Looks like that has been patched, so the new commits were not being logged. Changing this setting to "On push to source branch" resolves the issue.