gitlab-plugin
gitlab-plugin copied to clipboard
Cannot update Gitlab commit status on merge request build from fork
Context
- Gitlab plugin version: 1.4.5
- Gitlab version: 9.0.5-ee.0 (docker container)
- Jenkins version: 2.46.2
- Job type: Multibranch pipeline.
Logs & Traces
Here is the log from gitlab plugin:
May 09, 2017 9:11:48 AM INFO com.dabsquared.gitlabjenkins.webhook.GitLabWebHook getDynamic
WebHook called with url: /project/test-project
May 09, 2017 9:11:48 AM FINE com.dabsquared.gitlabjenkins.webhook.build.MergeRequestBuildAction
MergeRequest: {
"object_kind" : "merge_request",
"user" : {
"name" : "Asier Marruedo",
"username" : "a.marruedo",
"avatar_url" : "http://www.gravatar.com/avatar/791387a4e77ee997193f1cef33ac19cf?s=80&d=identicon"
},
"project" : {
"name" : "test-project",
"description" : "",
"web_url" : "http://local.gitlab.com/test/test-project",
"avatar_url" : null,
"git_ssh_url" : "[email protected]:test/test-project.git",
"git_http_url" : "http://local.gitlab.com/test/test-project.git",
"namespace" : "test",
"visibility_level" : 10,
"path_with_namespace" : "test/test-project",
"default_branch" : "master",
"homepage" : "http://local.gitlab.com/test/test-project",
"url" : "[email protected]:test/test-project.git",
"ssh_url" : "[email protected]:test/test-project.git",
"http_url" : "http://local.gitlab.com/test/test-project.git"
},
"object_attributes" : {
"id" : 23,
"target_branch" : "master",
"source_branch" : "poc-gitlab",
"source_project_id" : 39,
"author_id" : 2,
"assignee_id" : null,
"title" : "añadir steps de gitlab",
"created_at" : "2017-05-09 09:11:45 UTC",
"updated_at" : "2017-05-09 09:11:45 UTC",
"milestone_id" : null,
"state" : "opened",
"merge_status" : "unchecked",
"target_project_id" : 38,
"iid" : 1,
"description" : "",
"position" : 0,
"locked_at" : null,
"updated_by_id" : null,
"merge_error" : null,
"merge_params" : {
"force_remove_source_branch" : "0"
},
"merge_when_pipeline_succeeds" : false,
"merge_user_id" : null,
"merge_commit_sha" : null,
"deleted_at" : null,
"approvals_before_merge" : null,
"rebase_commit_sha" : null,
"in_progress_merge_commit_sha" : null,
"lock_version" : null,
"time_estimate" : 0,
"squash" : false,
"source" : {
"name" : "test-project",
"description" : "",
"web_url" : "http://local.gitlab.com/a.marruedo/test-project",
"avatar_url" : null,
"git_ssh_url" : "[email protected]:a.marruedo/test-project.git",
"git_http_url" : "http://local.gitlab.com/a.marruedo/test-project.git",
"namespace" : "a.marruedo",
"visibility_level" : 10,
"path_with_namespace" : "a.marruedo/test-project",
"default_branch" : "master",
"homepage" : "http://local.gitlab.com/a.marruedo/test-project",
"url" : "[email protected]:a.marruedo/test-project.git",
"ssh_url" : "[email protected]:a.marruedo/test-project.git",
"http_url" : "http://local.gitlab.com/a.marruedo/test-project.git"
},
"target" : {
"name" : "test-project",
"description" : "",
"web_url" : "http://local.gitlab.com/test/test-project",
"avatar_url" : null,
"git_ssh_url" : "[email protected]:test/test-project.git",
"git_http_url" : "http://local.gitlab.com/test/test-project.git",
"namespace" : "test",
"visibility_level" : 10,
"path_with_namespace" : "test/test-project",
"default_branch" : "master",
"homepage" : "http://local.gitlab.com/test/test-project",
"url" : "[email protected]:test/test-project.git",
"ssh_url" : "[email protected]:test/test-project.git",
"http_url" : "http://local.gitlab.com/test/test-project.git"
},
"last_commit" : {
"id" : "e9373884d6157c6ffd0d8ded5931c4aba3c3fbae",
"message" : "añadir steps de gitlab\n",
"timestamp" : "2017-05-09T10:58:13+02:00",
"url" : "http://local.gitlab.com/test/test-project/commit/e9373884d6157c6ffd0d8ded5931c4aba3c3fbae",
"author" : {
"name" : "developer",
"email" : "[email protected]"
}
},
"work_in_progress" : false,
"url" : "http://local.gitlab.com/test/test-project/merge_requests/1",
"action" : "open"
},
"repository" : {
"name" : "test-project",
"url" : "[email protected]:test/test-project.git",
"description" : "",
"homepage" : "http://local.gitlab.com/test/test-project"
}
}
May 09, 2017 9:12:08 AM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
Retrieving gitlab project ids
May 09, 2017 9:12:08 AM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
Retrieving the gitlab project id from remote url http://local.gitlab.com/test/test-project.git
May 09, 2017 9:12:08 AM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder
Call GitLab:
HTTP method: GET
URL: http://local.gitlab.com/api/v3/projects/test%2Ftest-project/repository/commits/e9373884d6157c6ffd0d8ded5931c4aba3c3fbae
Request headers: [
Accept = [application/json],
PRIVATE-TOKEN = [****FILTERED****]
]
May 09, 2017 9:12:09 AM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder
Got response from GitLab:
URL: http://local.gitlab.com/api/v3/projects/test%2Ftest-project/repository/commits/e9373884d6157c6ffd0d8ded5931c4aba3c3fbae
Status: 200 OK
Response headers: [
Cache-Control = [max-age=0, private, must-revalidate],
Connection = [keep-alive],
Content-Length = [549],
Content-Type = [application/json],
Date = [Tue, 09 May 2017 09:12:09 GMT],
Etag = [W/"74a4d8616ce09f1122b2ff09d68e0df4"],
Server = [nginx/1.11.3],
Strict-Transport-Security = [max-age=31536000],
Vary = [Origin],
X-Request-Id = [88e3d199-85cd-494c-b390-87d79a107b5c],
X-Runtime = [0.064516]
]
Response body: {
"id" : "e9373884d6157c6ffd0d8ded5931c4aba3c3fbae",
"short_id" : "e9373884",
"title" : "añadir steps de gitlab",
"created_at" : "2017-05-09T10:58:13.000+02:00",
"parent_ids" : [ "2c402328d853a00c9d7e06f757820c77d10db513" ],
"message" : "añadir steps de gitlab\n",
"author_name" : "developer",
"author_email" : "[email protected]",
"authored_date" : "2017-05-09T10:58:13.000+02:00",
"committer_name" : "developer",
"committer_email" : "[email protected]",
"committed_date" : "2017-05-09T10:58:13.000+02:00",
"stats" : {
"additions" : 73,
"deletions" : 56,
"total" : 129
},
"status" : null
}
May 09, 2017 9:12:09 AM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder
Call GitLab:
HTTP method: POST
URL: http://local.gitlab.com/api/v3/projects/test%2Ftest-project/statuses/e9373884d6157c6ffd0d8ded5931c4aba3c3fbae
Request headers: [
Accept = [application/json],
Content-Type = [application/x-www-form-urlencoded],
PRIVATE-TOKEN = [****FILTERED****]
]
May 09, 2017 9:12:09 AM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder
Got response from GitLab:
URL: http://local.gitlab.com/api/v3/projects/test%2Ftest-project/statuses/e9373884d6157c6ffd0d8ded5931c4aba3c3fbae
Status: 404 Not Found
Response headers: [
Cache-Control = [no-cache],
Connection = [keep-alive],
Content-Length = [49],
Content-Type = [application/json],
Date = [Tue, 09 May 2017 09:12:09 GMT],
Server = [nginx/1.11.3],
Vary = [Origin],
X-Request-Id = [73a06230-72c7-486b-bbfc-ce024e206e4e],
X-Runtime = [0.072932]
]
Response body: {
"message" : "404 References for commit Not Found"
}
May 09, 2017 9:12:09 AM SEVERE com.dabsquared.gitlabjenkins.util.CommitStatusUpdater updateCommitStatus
Failed to update Gitlab commit status for project 'test/test-project'
javax.ws.rs.NotFoundException: HTTP 404 Not Found
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.handleErrorStatus(ClientInvocation.java:201)
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.sun.proxy.$Proxy122.changeBuildStatus(Unknown Source)
at com.dabsquared.gitlabjenkins.util.CommitStatusUpdater.updateCommitStatus(CommitStatusUpdater.java:48)
at com.dabsquared.gitlabjenkins.workflow.GitLabBuildsStep$Execution$1.onStart(GitLabBuildsStep.java:72)
at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution.launch(CpsBodyExecution.java:124)
at org.jenkinsci.plugins.workflow.cps.CpsBodyInvoker.launch(CpsBodyInvoker.java:170)
at org.jenkinsci.plugins.workflow.cps.DSL$ThreadTaskImpl.invokeBody(DSL.java:499)
at org.jenkinsci.plugins.workflow.cps.DSL$ThreadTaskImpl.eval(DSL.java:469)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:175)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:330)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:242)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:230)
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:112)
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:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Problem description
- Create repository A. (test/test-project)
- Create fork from A, lets name it B (a.marruedo/test-project)
- Make changes and commit to B.
- Merge request from B to A.
When the plugin tries to update the commit status it fails with "message" : "404 References for commit Not Found"
If I manually curl the gitlab API, setting in the URL state
parameter, the it succeedes, and I am able to see the pipeline in the Gitlab UI.