Add tags field to runner in job/pipeline webhooks
What does this MR do?
This MR adds a tags
array of names to the runner
object in Job and Pipeline webhooks. It lists the same values that are present in the CI_RUNNER_TAGS
environment variable passed to a runner.
This allows customers running self-hosted runner fleets to determine if jobs are being assigned to runners with given tags.
There should be no risk with this change since it is just adding an additional field of an already listed object.
Tests
I created a webhook sink at https://requestbin.com/ and used the endpoint to create a webhook for job and pipeline changes on a local GDK instance project.
The builds were run on a runner with the local-gdk
mac
shell
tags:
The new tags
field is visible in the payloads that resulted (see below).
Input
.gitlab-ci.yaml
build:
script:
- printenv
- echo Done
tags: [local-gdk]
Output
Job start webhook payload
{
"object_kind": "build",
"ref": "webhooks",
"tag": false,
"before_sha": "66e3f2c45cc0be9f9f39ca7657ba06a242f3def8",
"sha": "44c12232a715aca150e460ba53294dbb680efdb3",
"build_id": 1149,
"build_name": "build",
"build_stage": "test",
"build_status": "running",
"build_started_at": "2021-01-13 17:57:05 UTC",
"build_finished_at": null,
"build_duration": 0.619811,
"build_allow_failure": false,
"build_failure_reason": "unknown_failure",
"pipeline_id": 147,
"runner": {
"id": 3,
"description": "Local GDK shell runner",
"active": true,
"is_shared": false,
"tags": [
"mac",
"local-gdk",
"shell"
]
},
"project_id": 20,
"project_name": "Administrator / playground",
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"email": "admin@example.com"
},
"commit": {
"id": 147,
"sha": "44c12232a715aca150e460ba53294dbb680efdb3",
"message": "Update .gitlab-ci.yml",
"author_name": "Administrator",
"author_email": "admin@example.com",
"author_url": "http://gdk.localhost:3000/root",
"status": "pending",
"duration": null,
"started_at": null,
"finished_at": null
},
"repository": {
"name": "playground",
"url": "ssh://pedropombeiro@gdk.localhost:2222/root/playground.git",
"description": "",
"homepage": "http://gdk.localhost:3000/root/playground",
"git_http_url": "http://gdk.localhost:3000/root/playground.git",
"git_ssh_url": "ssh://pedropombeiro@gdk.localhost:2222/root/playground.git",
"visibility_level": 0
}
}
Pipeline start webhook payload
{
"object_kind": "pipeline",
"object_attributes": {
"id": 147,
"ref": "webhooks",
"tag": false,
"sha": "44c12232a715aca150e460ba53294dbb680efdb3",
"before_sha": "66e3f2c45cc0be9f9f39ca7657ba06a242f3def8",
"source": "push",
"status": "running",
"detailed_status": "running",
"stages": [
"test"
],
"created_at": "2021-01-13 17:56:54 UTC",
"finished_at": null,
"duration": null,
"variables": []
},
"merge_request": null,
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"email": "admin@example.com"
},
"project": {
"id": 20,
"name": "playground",
"description": "",
"web_url": "http://gdk.localhost:3000/root/playground",
"avatar_url": null,
"git_ssh_url": "ssh://pedropombeiro@gdk.localhost:2222/root/playground.git",
"git_http_url": "http://gdk.localhost:3000/root/playground.git",
"namespace": "Administrator",
"visibility_level": 0,
"path_with_namespace": "root/playground",
"default_branch": "master",
"ci_config_path": null
},
"commit": {
"id": "44c12232a715aca150e460ba53294dbb680efdb3",
"message": "Update .gitlab-ci.yml",
"title": "Update .gitlab-ci.yml",
"timestamp": "2021-01-13T18:56:51+01:00",
"url": "http://gdk.localhost:3000/root/playground/-/commit/44c12232a715aca150e460ba53294dbb680efdb3",
"author": {
"name": "Administrator",
"email": "admin@example.com"
}
},
"builds": [
{
"id": 1149,
"stage": "test",
"name": "build",
"status": "running",
"created_at": "2021-01-13 17:56:54 UTC",
"started_at": "2021-01-13 17:57:05 UTC",
"finished_at": null,
"when": "on_success",
"manual": false,
"allow_failure": false,
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"email": "admin@example.com"
},
"runner": {
"id": 3,
"description": "Local GDK shell runner",
"active": true,
"is_shared": false,
"tags": [
"mac",
"local-gdk",
"shell"
]
},
"artifacts_file": {
"filename": null,
"size": null
}
}
]
}
Pipeline end webhook payload
{
"object_kind": "pipeline",
"object_attributes": {
"id": 147,
"ref": "webhooks",
"tag": false,
"sha": "44c12232a715aca150e460ba53294dbb680efdb3",
"before_sha": "66e3f2c45cc0be9f9f39ca7657ba06a242f3def8",
"source": "push",
"status": "success",
"detailed_status": "passed",
"stages": [
"test"
],
"created_at": "2021-01-13 17:56:54 UTC",
"finished_at": "2021-01-13 17:57:09 UTC",
"duration": 2,
"variables": []
},
"merge_request": null,
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"email": "admin@example.com"
},
"project": {
"id": 20,
"name": "playground",
"description": "",
"web_url": "http://gdk.localhost:3000/root/playground",
"avatar_url": null,
"git_ssh_url": "ssh://pedropombeiro@gdk.localhost:2222/root/playground.git",
"git_http_url": "http://gdk.localhost:3000/root/playground.git",
"namespace": "Administrator",
"visibility_level": 0,
"path_with_namespace": "root/playground",
"default_branch": "master",
"ci_config_path": null
},
"commit": {
"id": "44c12232a715aca150e460ba53294dbb680efdb3",
"message": "Update .gitlab-ci.yml",
"title": "Update .gitlab-ci.yml",
"timestamp": "2021-01-13T18:56:51+01:00",
"url": "http://gdk.localhost:3000/root/playground/-/commit/44c12232a715aca150e460ba53294dbb680efdb3",
"author": {
"name": "Administrator",
"email": "admin@example.com"
}
},
"builds": [
{
"id": 1149,
"stage": "test",
"name": "build",
"status": "success",
"created_at": "2021-01-13 17:56:54 UTC",
"started_at": "2021-01-13 17:57:05 UTC",
"finished_at": "2021-01-13 17:57:08 UTC",
"when": "on_success",
"manual": false,
"allow_failure": false,
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"email": "admin@example.com"
},
"runner": {
"id": 3,
"description": "Local GDK shell runner",
"active": true,
"is_shared": false,
"tags": [
"mac",
"local-gdk",
"shell"
]
},
"artifacts_file": {
"filename": null,
"size": null
}
}
]
}
Job end webhook payload
{
"object_kind": "build",
"ref": "webhooks",
"tag": false,
"before_sha": "66e3f2c45cc0be9f9f39ca7657ba06a242f3def8",
"sha": "44c12232a715aca150e460ba53294dbb680efdb3",
"build_id": 1149,
"build_name": "build",
"build_stage": "test",
"build_status": "success",
"build_started_at": "2021-01-13 17:57:05 UTC",
"build_finished_at": "2021-01-13 17:57:08 UTC",
"build_duration": 2.801132,
"build_allow_failure": false,
"build_failure_reason": "unknown_failure",
"pipeline_id": 147,
"runner": {
"id": 3,
"description": "Local GDK shell runner",
"active": true,
"is_shared": false,
"tags": [
"mac",
"local-gdk",
"shell"
]
},
"project_id": 20,
"project_name": "Administrator / playground",
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"email": "admin@example.com"
},
"commit": {
"id": 147,
"sha": "44c12232a715aca150e460ba53294dbb680efdb3",
"message": "Update .gitlab-ci.yml",
"author_name": "Administrator",
"author_email": "admin@example.com",
"author_url": "http://gdk.localhost:3000/root",
"status": "success",
"duration": 2,
"started_at": "2021-01-13 17:57:06 UTC",
"finished_at": "2021-01-13 17:57:09 UTC"
},
"repository": {
"name": "playground",
"url": "ssh://pedropombeiro@gdk.localhost:2222/root/playground.git",
"description": "",
"homepage": "http://gdk.localhost:3000/root/playground",
"git_http_url": "http://gdk.localhost:3000/root/playground.git",
"git_ssh_url": "ssh://pedropombeiro@gdk.localhost:2222/root/playground.git",
"visibility_level": 0
}
}
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Closes to #255394 (closed)