Resource Group Custom Attributes
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Problem to solve
There is great use in being able to define and update custom attributes from within a GitLab CI job.
Take, for instance, an atomic counter that must deterministically increment each time a specific job is run. Today, there is no solution for this that is accessible from the normal Developer role, nor enforces safe concurrency across other jobs or pipelines.
Proposal
Using the CI_JOB_TOKEN predefined variable, a GitLab CI job would be able to make HTTP requests to a resource-group-specific extension of the Custom Attributes API. These HTTP requests must be authenticated with CI_JOB_TOKEN, which is only valid while the given job is running, and only when the given job is running with the matching resource_group specified. Use of any other credential or token is not supported, nor is attempting to access the below APIs with a resource_group that doesn't match the one assigned to the current job.
List Attributes
GET /projects/:id/resource_groups/:key/custom_attributes
curl --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "https://gitlab.example.com/api/v4/projects/3/resource_groups/production/custom_attributes"
[
{
"key": "location",
"value": "Antarctica"
},
{
"key": "role",
"value": "Developer"
}
]
Single Attribute
GET /projects/:id/resource_groups/:key/custom_attributes/:attribute_key
curl --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "https://gitlab.example.com/api/v4/projects/3/resource_groups/production/custom_attributes/location"
{
"key": "location",
"value": "Antarctica"
}
Set Single Attribute
PUT /projects/:id/resource_groups/:key/custom_attributes/:attribute_key
curl --request PUT --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" -data "value=Greenland" "https://gitlab.example.com/api/v4/projects/3/resource_groups/production/custom_attributes/location"
{
"key": "location",
"value": "Greenland"
}
Delete Single Attribute
DELETE /projects/:id/resource_groups/:key/custom_attributes/:attribute_key
curl --request DELETE --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "https://gitlab.example.com/api/v4/projects/3/resource_groups/production/custom_attributes/location"
Intended users
Software Engineers and Release Managers.
Feature Usage Metrics
Unknown.
Does this feature require an audit event?
No.