Skip to content

images: Export published image refs as dotenv report

Dduvall requested to merge review/export-published-image into main

GitLab CI allows one to export environment variables from one job to another through the use of the dotenv report.

See https://docs.gitlab.com/ee/ci/variables/index.html#pass-an-environment-variable-to-another-job

Use a dotenv report to export variables that contain information about the published image. Each variable is prefixed by the name of the job which published the image with - replaced by _.

This should allow, among other use cases, a job to directly run an image built in a previous stage using native GitLab CI constructs.

build-foo:
  stage: build
  extends: [.kokkuri:build-and-publish-image]
  variables:
    BUILD_VARIANT: foo

run-foo:
  stage: run
  image: ${BUILD_FOO_IMAGE_REF}
  script:
    - echo "doing stuff with the image from build-foo"

Merge request reports