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

updateGitlabCommitStatus doesn't work with multibranch pipeline #919

Open dominik42 opened 5 years ago

dominik42 commented 5 years ago

Issue

For any multibranch pipeline job, the gitlab status isn't updated., but it works perfectly for normal pipeline jobs. The gitlab project name of this failed jobs contains group and subgroup names, separated by / (slash). This slash is then URL encoded by the gitlab plugin for building the request URL at gitlab site for retrieving project releated infos (ids, commits etc.) Those requests failed with 404 Not found. Already stumple upon #462 and #691 but I do not see that it should be an nginx@gitlab issue. I also configured the gitlab connection for the multi branch pipeline:

    properties(currentBuild.getRawBuild().getParent().getAllProperties())
    properties([disableConcurrentBuilds()])
    properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '5']]])
    properties([[$class: 'GitLabConnectionProperty', gitLabConnection: 'gitlab']])
    properties([ gitLabConnection('gitlab')] )

I'm wondering that for other non-multibranch-jobs, the retrieving of the project ids from gitlab returns successfully and those ids are used for the URLs afterwards. For the failing multibranch jobs, this retrieving failed and then this encoded project name

Context

Logs & Traces

Apr 12, 2019 11:53:09 AM FINE com.dabsquared.gitlabjenkins.webhook.build.PushBuildAction

Notify scmSourceOwner fashion42-backend-build-multibranch about changes for https://git.todo42.de/fashion42/backend/core.git

Apr 12, 2019 11:53:16 AM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds

Retrieving gitlab project ids

Apr 12, 2019 11:53:16 AM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater addGitLabBranchBuild

Retrieving the gitlab project id from remote url https://git.todo42.de/fashion42/backend/core.git

Apr 12, 2019 11:53:16 AM FINEST com.dabsquared.gitlabjenkins.gitlab.api.impl.ResteasyGitLabClientBuilder

Call GitLab:
HTTP method: GET
URL: https://git.todo42.de/api/v4/user
Request headers: [
Accept = [application/json],
PRIVATE-TOKEN = [****FILTERED****]
]

Apr 12, 2019 11:53:16 AM FINEST com.dabsquared.gitlabjenkins.gitlab.api.impl.ResteasyGitLabClientBuilder

Got response from GitLab:
URL: https://git.todo42.de/api/v4/user
Status: 200 OK

...

Apr 12, 2019 11:53:16 AM FINEST com.dabsquared.gitlabjenkins.gitlab.api.impl.ResteasyGitLabClientBuilder

Call GitLab:
HTTP method: GET
URL: https://git.todo42.de/api/v4/projects/fashion42%2Fbackend%2Fcore/repository/commits/8627c5e2853389a16cceae27c1ba2af4bc5c177a
Request headers: [
Accept = [application/json],
PRIVATE-TOKEN = [****FILTERED****]
]

Apr 12, 2019 11:53:16 AM FINEST com.dabsquared.gitlabjenkins.gitlab.api.impl.ResteasyGitLabClientBuilder

Got response from GitLab:
URL: https://git.todo42.de/api/v4/projects/fashion42%2Fbackend%2Fcore/repository/commits/8627c5e2853389a16cceae27c1ba2af4bc5c177a
Status: 404 Not Found
rocketbitz commented 5 years ago

have you found a workaround?

dominik42 commented 5 years ago

No.

jhagege commented 5 years ago

+1

iffonox commented 4 years ago

I've had the same issue on my gitlab server as well. It turned out to be be a problem with my apache reverse proxy configuration. Adding nocanon to ProxyPass and adding AllowEncodedSlashes NoDecode solved it.

The bug report https://gitlab.com/gitlab-org/gitlab-foss/issues/35079#note_76374269 was very helpful for fixing it on my side.

antoniologa commented 1 month ago

Hello! Is there any update on this? I'm currently trying to set up a Multibranch pipeline project that will listen to a GitLab webhook for merge request events and will trigger a build for each branch but as you mentioned the updateGitlabCommitStatus is not updating anything on GitLab. And I can see on the logs updateGitlabCommitStatus being called with no errors but nothing updating on GitLab with the current pipeline

If I set a regular pipeline project it all works as expected. But there is the issue of only having one workspace per branch which is why I wanted to have a Multibranch project to have everything separated

EDIT: