Post

How to transfer gitlab calculated variable into trigger section

How to transfer gitlab calculated variable into trigger section

One has to used artifacts section combined with reports child keyword and save a variable with its value to build.env file. https://techhelpnotes.com/gitlab-ci-pass-variable-to-a-trigger-stage/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
create_profile:
  stage: build
  script:
  # calculate APPLICATION_VERSION
    - echo APPLICATION_VERSION=0.1.0 >> build.env
    - echo Create profile ${APPLICATION_NAME} with version ${APPLICATION_VERSION}
  artifacts:
    paths:
      - profile
    reports:
      dotenv: build.env

trigger_upload:
  stage: release
  variables:
    PROFILE_NAME: ${APPLICATION_NAME}
    PROFILE_VERSION: ${APPLICATION_VERSION}
  trigger:
    project: git-project/profile-uploader
    strategy: depend
  needs:
    - job: create_profile
      artifacts: true
This post is licensed under CC BY 4.0 by the author.