Gitlab - 将父管道的作业ID传递给子管道

Gitlab - passing job id of parent pipeline to child pipeline

有什么方法可以将父管道的作业 ID 作为变量传递给子管道

包:

阶段:包
脚本:

- zip -r ./service.zip

部署:

阶段:部署
变量:

触发器:
包括:

  - project: '<namespace>/<project>'

    ref: '<branch>'

    file: '<path to yml file>'

strategy: depend    
    

是的,Gitlab 支持它。您需要传递 CI_PIPELINE_ID 内置变量。


.trigger_deploy:
  stage: deploy
  strategy: depend
  trigger:
    include:
       - project: '<namespace>/<project>'
         ref: '<branch>'
         file: '<path to yml file>'
  variables:
      PARENT_PIPELINE_ID: $CI_PIPELINE_ID
      PARENT_JOB_ID: $CI_JOB_ID

您可以在 Gitlab predefined variables documentation

中归档这些和更多变量