Gitlab-plugin: gitlabCommitStatus having failed to update bad request for freestyle / pipeline projects

Created on 6 Mar 2017  路  11Comments  路  Source: jenkinsci/gitlab-plugin

Issue

Context

  • Gitlab plugin version: 1.45
  • Gitlab version: 8.17.2-ee
  • Jenkins version: 2.32.3
  • Job type: Pipeline, Freestyle, Matrix, etc.

Logs & Traces

Failed to update Gitlab commit status for project 'xxx': HTTP 400 Bad Request

Problem description

I have a private repository on https://gitlab.com. When trying to use following in jenkins pipeline file

gitlabCommitStatus("build") {
        // your build steps
    }

Receiving the error:
Failed to update Gitlab commit status for project 'xxx': HTTP 400 Bad Request

I have tried using freestyle project and setup from jenkins UI, still getting the same error. Jenkins running on windows server.

doc improvement

Most helpful comment

Just for others who may stumble on this. My issue is that I was trying to describe gitLabBuilds before my main project SCM checkout, and then update them afterwards. This had the weird side-effect of creating GitLab Pipeline jobs for the repo which contains my Jenkinsfile (not the same repo as my main one), and so the attempts to update the status of the wrong repo may well have caused this error.

Took me a minute to relaise gitlabBuilds and gitlabCommitStatus update the last repo checked out, and if the ordering is wrong, it'll try to update the Jenkinsfile repo instead.

All 11 comments

looks like you closed this, but how did you solve it? I'm running into the same thing.

@tanveer-ali I'm running into a 400 response issue as well. How did you manage to solve this issue, or identify the root cause?

I'm having the same problem, how did you solve this issue?

Having the same problem here, but appears to be happening when trying to update a Stage that had previously received an updated status from another build on the same commit/PR.

For people still having this problem, can you follow the instructions in the User Support section of the README, post logs from your Jenkins server, and also look at the logs on the GitLab side? Those may give more insight into why GitLab is rejecting the request from Jenkins.

Just for others who may stumble on this. My issue is that I was trying to describe gitLabBuilds before my main project SCM checkout, and then update them afterwards. This had the weird side-effect of creating GitLab Pipeline jobs for the repo which contains my Jenkinsfile (not the same repo as my main one), and so the attempts to update the status of the wrong repo may well have caused this error.

Took me a minute to relaise gitlabBuilds and gitlabCommitStatus update the last repo checked out, and if the ordering is wrong, it'll try to update the Jenkinsfile repo instead.

@petewilcock thanks, that's a good find! I'll add something to the doc about this.

I am also facing the same issue intermittently in the builds in Jenkins. Is there any solution for this issue? Below is the error.

"Failed to update Gitlab commit status for project 'xxxx': HTTP 400 Bad Request"

I believe this also occurs if you're re-running a build (either resending the hook manually, or rebuilding) to a merge request that has already been merged/closed. Seems like you can't update the status of merged PRs, which makes sense. Possible to add some informational messages for that scenario?

For me, this happens intermittently when working even without a merge request, just on a feature branch.

The BadRequestException: HTTP 400 Bad Request is always thrown when we use a shared library in a pipeline as explained here: https://jenkins.io/doc/book/pipeline/shared-libraries/.
Obviously Jenkins clones two repositories to build any project: (1) shared library, and (2) project repository.
Now the com.dabsquared.gitlabjenkins.util.CommitStatusUpdater tries to update the status of both repositories each time the status has changed. And it throws the BadRequestException for the shared library all the time:

~
Feb 06, 2018 11:25:36 PM com.dabsquared.gitlabjenkins.util.CommitStatusUpdater updateCommitStatus
SEVERE: Failed to update Gitlab commit status for project 'group/jenkins-shared-lib'
javax.ws.rs.BadRequestException: HTTP 400 Bad Request
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.handleErrorStatus(ClientInvocation.java:197)
at org.jboss.resteasy.client.jaxrs.internal.proxy.extractors.DefaultEntityExtractorFactory$3.extractEntity(DefaultEntityExtractorFactory.java:50)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:104)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:64)
at com.dabsquared.gitlabjenkins.gitlab.api.impl.$Proxy127.changeBuildStatus(Unknown Source)
at com.dabsquared.gitlabjenkins.gitlab.api.impl.ResteasyGitLabClient.changeBuildStatus(ResteasyGitLabClient.java:60)
at com.dabsquared.gitlabjenkins.gitlab.api.impl.AutodetectingGitLabClient$7.execute(AutodetectingGitLabClient.java:112)
at com.dabsquared.gitlabjenkins.gitlab.api.impl.AutodetectingGitLabClient$7.execute(AutodetectingGitLabClient.java:109)
at com.dabsquared.gitlabjenkins.gitlab.api.impl.AutodetectingGitLabClient$GitLabOperation.execute(AutodetectingGitLabClient.java:296)
at com.dabsquared.gitlabjenkins.gitlab.api.impl.AutodetectingGitLabClient$GitLabOperation.access$100(AutodetectingGitLabClient.java:293)
at com.dabsquared.gitlabjenkins.gitlab.api.impl.AutodetectingGitLabClient.execute(AutodetectingGitLabClient.java:289)
at com.dabsquared.gitlabjenkins.gitlab.api.impl.AutodetectingGitLabClient.changeBuildStatus(AutodetectingGitLabClient.java:108)
at com.dabsquared.gitlabjenkins.util.CommitStatusUpdater.updateCommitStatus(CommitStatusUpdater.java:58)
at com.dabsquared.gitlabjenkins.workflow.GitLabBuildsStep$GitLabBuildStepExecution$1.onStart(GitLabBuildsStep.java:85)
at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution.launch(CpsBodyExecution.java:127)
at org.jenkinsci.plugins.workflow.cps.CpsBodyInvoker.launch(CpsBodyInvoker.java:170)
at org.jenkinsci.plugins.workflow.cps.DSL$ThreadTaskImpl.invokeBody(DSL.java:584)
at org.jenkinsci.plugins.workflow.cps.DSL$ThreadTaskImpl.eval(DSL.java:554)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:184)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:331)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:82)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:243)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:231)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
~

Was this page helpful?
0 / 5 - 0 ratings