gitlab-plugin icon indicating copy to clipboard operation
gitlab-plugin copied to clipboard

Feature: Stop Jenkins build if the related Gitlab pipeline has been canceled

Open trunov-ms opened this issue 8 years ago • 9 comments

If I cancel pipeline in GitLab Jenkins get response from Gitlab like this

Aug 19, 2017 5:01:27 PM FINEST com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder
Got response from GitLab:
URL: https://gitlab.local/api/v3/projects/724/repository/commits/cd3a7656bff11f26dd525f6e9a72e3b8ef4acf2b
Status: 200 OK
Response headers: [
Cache-Control = [max-age=0, private, must-revalidate],
Connection = [keep-alive],
Content-Length = [565],
Content-Type = [application/json],
Date = [Sat, 19 Aug 2017 12:01:27 GMT],
Etag = [W/"048f9623f241e8b4e01feaf9df2f9af4"],
Server = [nginx],
Strict-Transport-Security = [max-age=31536000],
Vary = [Origin],
X-Frame-Options = [SAMEORIGIN],
X-Request-Id = [730a5830-50ed-4d7e-bf0f-05931d46a4e2],
X-Runtime = [0.027535]
]
Response body: {
  "id" : "cd3a7656bff11f26dd525f6e9a72e3b8ef4acf2b",
  "short_id" : "cd3a7656",
  "title" : "Update README.md",
  "created_at" : "2017-08-19T17:00:12.000+05:00",
  "parent_ids" : [ "46586ec4ea96e1096a24b8929213248080603c6a" ],
  "message" : "Update README.md",
  "author_name" : "commiter name",
  "author_email" : "commiter email",
  "authored_date" : "2017-08-19T17:00:12.000+05:00",
  "committer_name" : "commiter name",
  "committer_email" : "commiter email",
  "committed_date" : "2017-08-19T17:00:12.000+05:00",
  "stats" : {
    "additions" : 3,
    "deletions" : 0,
    "total" : 3
  },
  "status" : "canceled"
}

I can see "status" : "canceled" in this response. Is it possible to stop Jenkins build if the related Gitlab pipeline has been canceled? Or remove the build from the Jenkins queue if it is not already running.

trunov-ms avatar Aug 19 '17 12:08 trunov-ms

Interesting feature request. I didn't know you could do this in GitLab. It seems a little strange to use the GitLab UI to cancel Jenkins builds, but in theory we could support this. I won't have time to build it, but if someone wants to submit a PR we would definitely consider it.

omehegan avatar Aug 29 '17 18:08 omehegan

I also want this.

sebastienbonami avatar Nov 20 '17 19:11 sebastienbonami

@omehegan for me, it's not that strange. Because this plugin is so powerful that all absolutely needed information about builds are available in our Gitlab instance, which is the place where we work. Jenkins consultation becomes optional, except for failed builds.

Thanks all for your job :)

daks avatar Nov 21 '17 08:11 daks

I want this feature as well. From a GitLab user's perspective, it's even a bit unexpected that cancelling a pipeline inside GitLab does not actually stop it from running.

chinhodado avatar Feb 07 '18 17:02 chinhodado

Any news on this?

sebastienbonami avatar Mar 19 '18 21:03 sebastienbonami

I need this feature as well. If I cancel a build job in GitLab, the icon will be "cancelled". But the job in Jenkins is still running (or pending if there is a previous job running). After all queued jobs done, the icons in GitLab may be in wrong status.

linzhenan avatar May 28 '18 03:05 linzhenan

+1

Is a workaround available?

bwaldvogel avatar Sep 21 '18 09:09 bwaldvogel

No workaround available. This would require a change to the plugin to respond to the 'cancelled' message from GitLab. As I said previously, I'm not in a position to work on that, but if anyone else wants to I would be happy to review a PR.

omehegan avatar Sep 24 '18 20:09 omehegan

No workaround available. This would require a change to the plugin to respond to the 'cancelled' message from GitLab. As I said previously, I'm not in a position to work on that, but if anyone else wants to I would be happy to review a PR.

I'll take this issue, let's talk before I start implementing anything.

BarrMan avatar Aug 15 '24 11:08 BarrMan