Skip to content

Introduce $CI_BUILD_REF_SLUG

Nick Thomas requested to merge (removed):22849-ci-build-ref-slug into master

What does this MR do?

Adds $CI_BUILD_REF_SLUG to the variables exposed to the runner. This is based on $CI_BUILD_REF_NAME but lowercased, shortened to 63 bytes maximum, and with characters invalid in URLs and domain names replaced with -.

Are there points in the code the reviewer needs to double check?

Slugs don't have a uniqueness guarantee. !7983 (merged) introduces an environment name slug which is unique, so I'm not as exercised about this as I was.

Should the slug be published in the API? It's available through the variables endpoint, but perhaps it should be part of GET /project/:id/builds ?

I've called it ref_slug rather than just slug as there are number of possibilities for slugification in a build (unlike an environment, where only the name makes sense to slugify).

Why was this MR needed?

$CI_BUILD_REF_NAME is not suited for URLs and domain names, given the list of valid characters in a git ref.

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes #22849 (closed)

Merge request reports