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

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

package:
  stage: package                 
  script:
    - zip -r ./service.zip

deploy:
  stage: deploy
  variables:

  trigger:         
    include:
      - project: '<namespace>/<project>'
        ref: '<branch>'
        file: '<path to yml file>'
    strategy: depend    
stack overflow Gitlab - passing job id of parent pipeline to child pipeline
原文答案
author avatar

接受的答案

是的,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 中归档这些和更多变量


答案: