Skip to content

Missing environment on build step in Auto DevOps

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

IMO the Auto DevOps build step should have:

environment:
  name: review/$CI_COMMIT_REF_NAME
  action: prepare

https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml#L4

Why is this important:

In frontend projects is very common to set environment variables during build time with tools like the Webpack EnvironmentPlugin. Right now there is no way to get this to work with Auto DevOps. At least not if you'd like to set different values based on the environment (e.g. for prod and testing). For example, if we'd like to set:

  • AUTO_DEVOPS_BUILD_IMAGE_EXTRA_ARGS: --build-arg API_URL=prod.example.com with scope production
  • AUTO_DEVOPS_BUILD_IMAGE_EXTRA_ARGS: --build-arg API_URL=dev.example.com with scope review/*

There is no way to archive this. The reason for this is that the build step does not define an environment. I thought this was a limitation of the environment feature but I just came across the environment:action field that could be set to prepare which allows setting the environment also for the build step to solve this issue.

I work with a digital Agency that has 100+ projects using GitLab CI/CD and is running into this issue again and again.

Edited by 🤖 GitLab Bot 🤖