jenkinsci / gitlab-plugin

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

gitlabCommitStatus returns 404 when branch name contains dot ('.') #1351

Open frtelg opened 1 year ago

frtelg commented 1 year ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.361.1 OS: Linux - 5.4.0-1085-aws --- Office-365-Connector:4.17.0 Parameterized-Remote-Trigger:3.1.6.1 ace-editor:1.1 active-directory:2.25.1 ansible:1.1 ansicolor:1.0.1 ant:475.vf34069fef73c antisamy-markup-formatter:2.7 apache-httpcomponents-client-4-api:4.5.13-1.0 authentication-tokens:1.4 aws-credentials:191.vcb_f183ce58b_9 aws-java-sdk:1.12.215-343.v953e693f0e86 aws-java-sdk-cloudformation:1.12.215-343.v953e693f0e86 aws-java-sdk-codebuild:1.12.215-343.v953e693f0e86 aws-java-sdk-ec2:1.12.215-343.v953e693f0e86 aws-java-sdk-ecr:1.12.215-343.v953e693f0e86 aws-java-sdk-ecs:1.12.215-343.v953e693f0e86 aws-java-sdk-elasticbeanstalk:1.12.215-343.v953e693f0e86 aws-java-sdk-iam:1.12.215-343.v953e693f0e86 aws-java-sdk-logs:1.12.215-343.v953e693f0e86 aws-java-sdk-minimal:1.12.215-343.v953e693f0e86 aws-java-sdk-sqs:1.12.215-343.v953e693f0e86 aws-java-sdk-ssm:1.12.215-343.v953e693f0e86 basic-branch-build-strategies:1.3.2 blueocean:1.25.5 blueocean-autofavorite:1.2.5 blueocean-bitbucket-pipeline:1.25.5 blueocean-commons:1.25.5 blueocean-config:1.25.5 blueocean-core-js:1.25.5 blueocean-dashboard:1.25.5 blueocean-display-url:2.4.1 blueocean-events:1.25.5 blueocean-git-pipeline:1.25.5 blueocean-github-pipeline:1.25.5 blueocean-i18n:1.25.5 blueocean-jwt:1.25.5 blueocean-personalization:1.25.5 blueocean-pipeline-api-impl:1.25.5 blueocean-pipeline-editor:1.25.5 blueocean-pipeline-scm-api:1.25.5 blueocean-rest:1.25.5 blueocean-rest-impl:1.25.5 blueocean-web:1.25.5 bootstrap4-api:4.6.0-5 bootstrap5-api:5.1.3-7 bouncycastle-api:2.26 branch-api:2.1046.v0ca_37783ecc5 build-name-setter:2.2.0 build-timeout:1.21 caffeine-api:2.9.3-65.v6a_47d0f4d1fe checks-api:1.7.4 cloudbees-bitbucket-branch-source:773.v4b_9b_005b_562b_ cloudbees-folder:6.729.v2b_9d1a_74d673 command-launcher:84.v4a_97f2027398 conditional-buildstep:1.4.2 config-file-provider:3.10.0 copyartifact:1.46.4 credentials:1129.vef26f5df883c credentials-binding:523.vd859a_4b_122e6 cucumber-reports:5.6.1 cucumber-testresult-plugin:0.10.1 database:148.v4a_ff2ca_608b_7 database-postgresql:1.2 date-parameter:0.0.4 description-setter:1.10 display-url-api:2.3.6 docker-build-step:2.8 docker-commons:1.19 docker-workflow:1.28 durable-task:496.va67c6f9eefa7 ec2:1.68 ec2-fleet:2.5.1 echarts-api:5.3.3-1 email-ext:2.89 envinject:2.866.v5c0403e3d4df envinject-api:1.199.v3ce31253ed13 extended-choice-parameter:346.vd87693c5a_86c extended-read-permission:3.2 favorite:2.4.1 filesystem-list-parameter-plugin:0.0.8 font-awesome-api:6.1.1-1 git:4.11.4 git-client:3.11.1 git-parameter:0.9.17 git-server:1.11 github:1.34.5 github-api:1.303-400.v35c2d8258028 github-branch-source:1677.v731f745ea_0cf gitlab-plugin:1.5.35 gradle:1.39.1 h2-api:1.4.199 handlebars:3.0.8 handy-uri-templates-2-api:2.1.8-22.v77d5b_75e6953 htmlpublisher:1.30 instance-identity:3.1 jackson2-api:2.13.3-285.vc03c0256d517 javadoc:217.v905b_86277a_2a_ javax-activation-api:1.2.0-3 javax-mail-api:1.6.2-6 jaxb:2.3.6-1 jdk-tool:1.5 jenkins-design-language:1.25.5 jersey2-api:2.36-2 jjwt-api:0.11.5-77.v646c772fddb_0 jnr-posix-api:3.1.7-3 jquery:1.12.4-1 jquery-detached:1.2.1 jquery3-api:3.6.0-4 jsch:0.1.55.2 junit:1119.1121.vc43d0fc45561 ldap:2.10 lockable-resources:2.15 mailer:414.vcc4c33714601 mapdb-api:1.0.9.0 matrix-auth:2.6.8 matrix-project:771.v574584b_39e60 maven-plugin:3.19 mina-sshd-api-common:2.8.0-21.v493b_6b_db_22c6 mina-sshd-api-core:2.8.0-21.v493b_6b_db_22c6 momentjs:1.1.1 node-iterator-api:1.5.1 nodelabelparameter:1.11.0 okhttp-api:4.9.3-105.vb96869f8ac3a pam-auth:1.10 parameterized-trigger:2.44 performance:3.20 pipeline-aws:1.43 pipeline-build-step:2.18 pipeline-github-lib:38.v445716ea_edda_ pipeline-graph-analysis:195.v5812d95a_a_2f9 pipeline-groovy-lib:593.va_a_fc25d520e9 pipeline-input-step:449.v77f0e8b_845c4 pipeline-milestone-step:101.vd572fef9d926 pipeline-model-api:2.2097.v33db_b_de764b_e pipeline-model-definition:2.2097.v33db_b_de764b_e pipeline-model-extensions:2.2097.v33db_b_de764b_e pipeline-rest-api:2.24 pipeline-stage-step:293.v200037eefcd5 pipeline-stage-tags-metadata:2.2097.v33db_b_de764b_e pipeline-stage-view:2.24 pipeline-utility-steps:2.13.0 plain-credentials:1.8 plugin-util-api:2.17.0 popper-api:1.16.1-3 popper2-api:2.11.5-2 postgresql-api:42.3.3 project-description-setter:1.2 pubsub-light:1.16 qtest:1.4.8 rebuild:1.34 resource-disposer:0.19 role-strategy:488.v0634ce149b_8c run-condition:1.5 scm-api:608.vfa_f971c5a_a_e9 script-security:1175.v4b_d517d6db_f0 snakeyaml-api:1.30.1 sse-gateway:1.25 ssh-credentials:277.v95c2fec1c047 ssh-slaves:1.821.vd834f8a_c390e sshd:3.242.va_db_9da_b_26a_c3 structs:318.va_f3ccb_729b_71 subversion:2.15.5 teams-webhook-trigger:0.1.1 timestamper:1.18 token-macro:293.v283932a_0a_b_49 tricentis-ci:1.3 trilead-api:1.57.v6e90e07157e1 variant:1.4 windows-slaves:1.8.1 workflow-aggregator:581.v0c46fa_697ffd workflow-api:1164.v760c223ddb_32 workflow-basic-steps:948.v2c72a_091b_b_68 workflow-cps:2725.v7b_c717eb_12ce workflow-durable-task-step:1146.v1a_d2e603f929 workflow-job:1186.v8def1a_5f3944 workflow-multibranch:716.vc692a_e52371b_ workflow-scm-step:400.v6b_89a_1317c9a_ workflow-step-api:625.vd896b_f445a_f8 workflow-support:820.vd1a_6cc65ef33 ws-cleanup:0.42 ```

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

Linux - 5.4.0-1085-aws

Reproduction steps

I have a feature brach with name: feature/update-base-image-1.10.22

Then I am sending updates to the gitlab commit as follows:

gitlabCommitStatus(name: 'integrationtest',
     builds: [
             [projectId: env.PROJECT_ID, revisionHash: "${params.COMPONENT_BRANCH}"], // params.COMPONENT_BRANCH is  'feature/update-base-image-1.10.22'
    ]) {
   // logic
}

Expected Results

No errors in pipeline, Gitlab MR is updated with the right status for 'integrationtest'.

Actual Results

Jenkins console shows:

[Pipeline] {
Failed to update Gitlab commit status for project 'test/test-project': HTTP 404 Not Found
[Pipeline] }
Failed to update Gitlab commit status for project 'test/test-project': HTTP 404 Not Found

Any other branch name will result in a successful build.

Anything else?

When I manually request the branch info using the Gitlab API (V4) I get a 200 OK response. GET https://gitlab.gdlaws.nl/api/v4/projects/149/repository/branches/feature%2Fupdate-base-image-to-1.10.22

rcfja commented 1 year ago

I've getting a 404 on master branch. I cannot find any configurations that are wrong. I'm praying this bug is related.

prince-panwar commented 1 year ago

This is because GitLab treats dots in branch names as a separator between the project namespace and the branch name, which can cause issues with the API endpoint.