Skip to content

Make user-defined CI variables available to docker build when using Auto Devops

Problem to solve

CI environment variables are not made available to docker build stage when using Auto DevOps.

Intended users

developers

Further details

Passing user defined CI variables to a docker build stage is a very common scenario that should be supported by Auto DevOps.

Proposal

Add a feature to CI/Runner which exposes all of the CI variables in another variable so we know what to pass through to the build container.

Previous proposal Provide a mechanism to indicate a CI variable should be made available to auto-build, this could be either:

A new variable that contains a list of the variable names to be passed to build stage

image

Permissions and Security

Documentation

Testing

What does success look like, and how can we measure that?

Measure usage of Auto DevOps variables

Links / references

Original issue content

Summary

Pass all environment variables to build step in default Auto DevOps template. During the build phase of our project it requires api keys that are set using CI environment variables. However, when the build is done (in this case using herokuish) the environment variables are not available.

Steps to reproduce

  • Define CI variable in project settings
  • Trigger auto devops pipeline

What is the current bug behavior?

Environment variables defined in CI variables settings are not available during the build phase of Auto DevOps

What is the expected correct behavior?

User defined CI variables should be available during the build phase of Auto DevOps

Possible fixes

From looking at the default Auto DevOps template it seems that there is a small subset of environment variables that are passed to the docker build step. A fix would be passing in all of the CI environment variables.

https://gitlab.com/gitlab-org/cluster-integration/auto-build-image/blob/master/src/build.sh#L26

Edited by Taurie Davis