ferdinand list

Masking gitlab ci/cd env variables using base64

A short note on de-/encoding gitlab ci/cd environment variables to base64 for masking |

Masking gitlab ci/cd env variables using base64

Gitlab has requirements with regards to special chars and length for environment variables to be maskable. These can be circumvented using base64 encoding which containss no special chars. Store the env variable encoded and masked and decode it during the execution of your gitlab pipeline.

Example: private ssh key §

Converting to base64:

    cat id_rsa_gitlab_cicd | base64 -w0 > id_rsa_gitlab_cicd_base64

Converting back to clear text inside your gitlab pipeline:

  script:
- echo "Deploying!"
- echo "${SSH_PRIVATE_KEY}" | base64 -d > id_rsa_gitlab_cicd_decoded