Add pipeline tier to pipeline name
What does this MR do and why?
Add pipeline tier to the pipeline name
Proof of work
There are unit tests for the biggest part of the logic.
For the logic that we cannot test (error handling with GitLab gem), I hade some manual testing:
Steps to reproduce
export CI_PIPELINE_NAME="Ruby 3.1 MR"
export CI_PROJECT_ID=278964
export CI_PIPELINE_ID=1220515019 # The pipeline for which we'll change the name
export CI_API_V4_URL=https://gitlab.com/api/v4
export PROJECT_TOKEN_FOR_CI_SCRIPTS_API_USAGE="${GITLAB_API_PRIVATE_TOKEN}"
export CI_JOB_TOKEN="${GITLAB_API_PRIVATE_TOKEN}"
export CI_MERGE_REQUEST_IID=1234
export CI_MERGE_REQUEST_LABELS="Engineering Productivity,ep::pipeline,feature::enhancement,type::feature,pipeline::tier-1"
Additionally, you'll have to change the line in the codebase where we set JOB-TOKEN
header, as we only have private tokens available locally:
# Before
request['JOB-TOKEN'] = ENV['CI_JOB_TOKEN']
# After
request['PRIVATE-TOKEN'] = ENV['CI_JOB_TOKEN']
No errors
$ scripts/pipeline/set_pipeline_name.rb
Labels from the MR: ["Engineering Productivity", "ep::pipeline", "feature::enhancement", "type::feature", "pipeline::tier-1"]
New pipeline name: Ruby 3.1 MR [tier:1, types:qa,code,rspec-predictive]
$ echo $? # should be 0
0
GitLab-related error
# Before
gitlab.pipeline_bridges(ENV['CI_PROJECT_ID'], ENV['CI_PIPELINE_ID']).auto_paginate do |job|
# After
gitlab.pipeline_bridges(ENV['CI_PROJECT_ID'], ENV['CI_PIPELINE_ID'] + '-woops').auto_paginate do |job|
$ scripts/pipeline/set_pipeline_name.rb
Labels from the MR: ["Engineering Productivity", "ep::pipeline", "feature::enhancement", "type::feature", "pipeline::tier-1"]
GitLab error: Server responded with code 400, message: pipeline_id is invalid. Request URI: https://gitlab.com/api/v4/projects/278964/pipelines/1220515019-woops/bridges
$ echo $? # should be 3
3
Other error
# Before
set_pipeline_name(pipeline_name)
# After
raise "WOOPS"; set_pipeline_name(pipeline_name)
$ scripts/pipeline/set_pipeline_name.rb
Labels from the MR: ["Engineering Productivity", "ep::pipeline", "feature::enhancement", "type::feature", "pipeline::tier-1"]
New pipeline name: Ruby 3.1 MR [tier:1, types:qa,code,rspec-predictive]
scripts/pipeline/set_pipeline_name.rb:67:in `execute': WOOPS (RuntimeError)
from scripts/pipeline/set_pipeline_name.rb:158:in `<main>'
$ echo $?
1
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Related to #459974 (closed)
Edited by David Dieulivol