passing variables between 2 stages, if stages have jobs in parallel

Problem to solve

I need to pass variables from Stage test to stage deploy.
Stage test has multiple jobs running in parallel(test0,test1,test2).
Every job(test) when succeeded, pass a variable called EVAL*=$CI_JOB_NAME (with * the number accorded to it [0,1,2]).
In deploy job should these variable in array stored(if any), and when we iterate through it we can see which test job has succeeded(according to name) and ready to deploy(merging to master). This approach is meant to be used with 50 tests in parallel. My Configuration is below, syntax is not relevant, it is only to demonstrate the idea.

test0:
  stage: test
  tags: [ci_test]
  script:
     - do something
     - if something: EVAL0=$CI_JOB_NAME
  artifacts:
    when: always 
test1:
  stage: test
  tags: [ci_test]
  script:
     - do something
     - if something: EVAL1=$CI_JOB_NAME
  artifacts:
    when: always
test2:
  stage: test
  tags: [ci_test]
  script:
     - do something
     - if something: EVAL2=$CI_JOB_NAME
  artifacts:
    when: always
deploy test:
  stage: deploy
  tags: [ci_test]
  script:
     - array+=($EVAL(i) for in (0,1,2)) 
     - for v in array; do echo v and do something with v;done
  artifacts:
    when: always

Question

Is it possible in Gitlab to do so, and if yes can you lead me through that procedure.

Hi, @samGit. The environment variables created during jobs are lost when the job finishes.

I would recommend saving your variables to files that can be collected by the GitLab Runner via the artifacts .gitlab-ci.yml attribute. The artifacts from all jobs will then be available to the job(s) in your next stage(s).

Here’s a minimal example: .gitlab-ci.yml · master · thiagocsf-group / copy-artefacts · GitLab