gitlab ci:在工件文件上添加作业 ID

gitlabci: add a job id on artifacts files

我想在工件中的文件名末尾添加构建签名。我可以是工作 ID 或工作 ID 和提交参考的组合。 目前我得到 image.slp 但我更喜欢得到 image.1.slpimage.1.e8f8c4ed.slp 之类的东西。这是我的 gitlab-ci.yml:

build-runner:
  stage: build
  script:
    - ./build.sh
    - cp ../output/image.slp .
  artifacts:
    paths:
       - image.slp

您应该可以通过 CI_JOB_ID 环境变量来实现。

有关您可以使用的可用变量的完整列表,请参阅 docs

可能这样的事情可以解决您的问题:

build-runner:
  stage: build
  script:
    - ./build.sh
    - cp ../output/image.slp image.$CI_JOB_ID.slp
  artifacts:
    paths:
       - image.$CI_JOB_ID.slp