Gitlab CI: Truncate variable names in the environment section

Description

Currently the CI_COMMIT_REF_SLUG is limited to 63 characters. However for some applications (Heroku, LetsEncrypt certificates) this is too long. I am wondering if something could be created that limits the amount of characters. This can be a serious limitation for review apps. Currently I am restricting the length of a branchname in order for my review apps to work.

I have seen syntax like:

${CI_COMMIT_REF_SLUG:0:20}
$${CI_COMMIT_REF_SLUG:0:20}
eval export REVIEW_APP_NAME=${REVIEW_APP_NAME}

The problem however is that these do not work in the environment section inside a CI Pipeline.

Suggestion

The ${CI_COMMIT_REF_SLUG:0:20} syntax should be supported for environments as well.

Additional Details

If users want this functionality available in script, grouprunner will need to implement that and as such, Category:Runner Core label has been added for now if that is the case for final implementation decision.

Proposal

#24659 (comment 1350635985)

  • Support variable truncation syntax on the GitLab side grouppipeline security
  • Support variable truncation syntax on the Runner side grouprunner
    • This can include support for other shell environments, or it can be separated into another issue. (The syntax is already supported in bash and sh.)
Edited by Max Orefice