job之间传递自定义变量的写法


...
variables:
  VARIABLES_FILE: ./variables.txt  # "." is required for image that have sh not bash

...

get-version:
  stage: prepare
  image: ...
  script:
    - APP_VERSION=...
    - echo "export APP_VERSION=$APP_VERSION" > $VARIABLES_FILE
  artifacts:
    paths:
      - $VARIABLES_FILE
...
package:
  stage: package
  image: ...
  script:
    - source $VARIABLES_FILE
    - echo "Use env var APP_VERSION here as you like ..."

相关