3

I can see who creates the Gitlab pipeline/job, however, is it possible to see who canceled it? Even better to receive a notification if it was canceled by someone.

As shown from the screenshot, the job is canceled, but not by me, and the output log is empty.

BTW, I checked the other job contains log and canceled while running, but still couldn't find who canceled it.

enter image description here

Chuan
  • 3,103
  • 1
  • 19
  • 23

2 Answers2

6

You cannot know this unless you check the logs.

There is an open issue about this: https://gitlab.com/gitlab-org/gitlab-ce/issues/31679

djuarezg
  • 2,307
  • 2
  • 20
  • 34
-2

This is possible via the GitLab jobs API, on Linux with a simple curl:

curl --header "PRIVATE-TOKEN: <personal-access-token>" https://gitlab/api/v4/projects/<project_id>/jobs/<job_id> | jq .

You can get the project_id from the projects main page, the job_id from the CI/CD -> jobs page and you can create a personal-access-token from the profile settings page, ensuring it has API permissions.

If you want to retrieve all jobs with cancelled status:

curl --header "PRIVATE-TOKEN: <personal-access-token>" https://gitlab/api/v4/projects/<project_id>/jobs?scope[]=canceled | jq .

The user JSON object in the output indicates who cancelled the job, eg:

"user": {
    "id": 77,
    "name": "John Doe",
    "username": "jdoe",
    "state": "active",
    "avatar_url": "https://gitlab/uploads/-/system/user/avatar/77/avatar.png",
    "web_url": "https://gitlab/jdoe",
    "created_at": "2017-08-14T13:53:37.796+01:00",
    "bio": "",
    "location": "",
    "public_email": "",
    "skype": "",
    "linkedin": "",
    "twitter": "",
    "website_url": "",
    "organization": ""
  }

Cheers

S

slowko
  • 829
  • 1
  • 7
  • 12
  • 2
    Thanks for your answer! I can retrieve some job info via the query, however, there is no information about who canceled the job. – Chuan Apr 04 '19 at 12:09
  • 10
    This is the user who triggered the pipeline, not the one who cancelled it – jaudo Jan 18 '22 at 08:38