3

I want to pass some variables between jobs (on other stages) in my gitlab-ci scrypt. I used as in example:

buildTest:
    stage: build
    artifacts:
        reports:
            dotenv: build.env
        name: "FullRelease"
        paths:
            - 'app'
        expire_in: 1 day
    script: |
        echo "version=1.2.3" >> build.env
....
runWin:
    stage: runOnWin
    variables:
        GIT_STRATEGY: none
    script: |
        echo "Version is %version%"
    needs:
        - job: buildTest
          artifacts: true

All is work, but I've got all artifacts from 'buildTest' (whole folder app, which is big). It's a bit strange, but it doesn't contains file 'build.env', which is only I need. Is there any possibility to pass only variables, without other artifacts. If I set artifacts: false - no variables are passed.

Tadeusz
  • 6,453
  • 9
  • 40
  • 58
  • Just remove `paths: - 'app'` if you don't want it? – slauth Nov 17 '21 at 08:23
  • I WANT it, but not in runWin job. I want to be able to downloand app as zip archive from web or inside other job (not runWin) to build docker image and so on. – Tadeusz Nov 17 '21 at 08:33
  • the question is, is the content of your build.env depending on how you create the `app` folder or can this be done in a separate job - which creates just the build.env :) – Simon Schrottner Nov 17 '21 at 08:56
  • Content of build.dev depends on source code, and from source code my app is built. If I divide job (one for build.dev and second for building app), then source code will be loaded twice. I want to escape this. – Tadeusz Nov 17 '21 at 09:05

2 Answers2

0

There is no other way but you can try to call the pipeline from a job with environment variables having GitLab pipeline API

Artem Ptushkin
  • 1,151
  • 9
  • 17
0

This is currently not possible, unfortunately. There is an open issue at GitLab with a proposal for this:

https://gitlab.com/gitlab-org/gitlab/-/issues/384028

Please comment there to gain attention for this topic.

carlfriedrich
  • 2,919
  • 1
  • 15
  • 29