Omeri
Omeri

Reputation: 347

GitLab - Including dynamically generated .yml file from '.pre' stage in 'build' stage

I am trying to dynamically generate a section of .yml file based on a variable set in .gitlab-ci.yml file, and then include the generated file as an artifact to be evaluated for future stages such as build.

I am running into issues trying to load in the build stage the generated yml in the .pre stage through an include. It does make sense that this would not be possible on the same run, but maybe I could leverage some possible feature which might make the generated file loaded on subsequent runs, maybe caching it somehow.

Is it possible to include generated templates (artifacts) on subsequent stages, maybe through caching the artifact?

Can you set an artifact to be included as a .yml template for later stages?

Upvotes: 0

Views: 1712

Answers (1)

Omeri
Omeri

Reputation: 347

I just discovered parent-child pipelines might be a possible solution for this and I will be trying this.

https://docs.gitlab.com/ee/ci/pipelines/parent_child_pipelines.html#dynamic-child-pipelines

From docs:

You can trigger a child pipeline from a dynamically generated configuration file:

generate-config:
  stage: build
  script: generate-ci-config > generated-config.yml
  artifacts:
    paths:
      - generated-config.yml

child-pipeline:
  stage: test
  trigger:
    include:
      - artifact: generated-config.yml
        job: generate-config

Upvotes: 1

Related Questions