我有一个像这样的简单舞台:
build-hw:
stage: build
when: on_success
timeout: 10 hours
before_script:
source /usr/local/bin/setup_env.sh
script:
- make build
- make export_hw sw/$SW_PRJ/xsa
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA"
expire_in: 1 hour
paths:
- $HW_PRJ/$HW_PRJ.runs/*.log
- $HW_PRJ/$HW_PRJ.runs/impl_1/top.bit
- $HW_PRJ/$HW_PRJ.runs/impl_1/top.ltx
- sw/$SW_PRJ/xsa/top.xsa
以及 .gitlab-ci 文件中设置的一些变量
variables:
HW_PRJ: "pl-build"
SW_PRJ: "ps-build"
我已经做了什么:
但它仅在 script 块内应用变量,而不是在 paths
中有什么解决办法吗? 预先感谢!
GitLab 对此有一套机制,您不必做太多事情。您只需将变量写入文件并将其声明为具有
dotenv
结尾的工件,然后(取决于您如何设置它)可能会列出依赖项。
$: cat .gitlab-ci.yml
stages:
- build
save-env:
stage: ".pre"
script: |
when=$(date +%s)
printf "%s\n" "thing1='foo'" "thing2='$when'" > sav.env
tags:
- VM
artifacts:
reports:
dotenv: sav.env
show-vars:
stage: build
script: echo "got [$thing1], [$thing2]"
tags:
- VM
dependencies:
- save-env
show-vars
日志的最后几行:
Executing "step_script" stage of the job script
$ echo "got [$thing1], [$thing2]"
got ['foo'], ['1711048904']
Cleaning up project directory and file based variables
Job succeeded