gitlab ci/cd 中 跨项目使用制品

举报
拿我格子衫来 发表于 2022/03/17 23:51:03 2022/03/17
【摘要】 gitlab ci/cd 中 跨项目使用制品 https://docs.gitlab.com/ee/ci/yaml/#needsproject build_job: stage: build ...

gitlab ci/cd 中 跨项目使用制品

https://docs.gitlab.com/ee/ci/yaml/#needsproject

build_job:
  stage: build
  script:
    - ls -lhR
  needs:
    - project: namespace/group/project-name
      job: build-1
      ref: main
      artifacts: true

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
build_job:
  stage: build
  script:
    - ls -lhR
  needs:
    - project: group/same-project-name
      job: build-1
      ref: other-ref
      artifacts: true

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
build_job:
  stage: build
  script:
    - ls -lhR
  needs:
    - project: $CI_PROJECT_PATH
      job: $DEPENDENCY_JOB_NAME
      ref: $ARTIFACTS_DOWNLOAD_REF
      artifacts: true

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

You can’t download artifacts from jobs that run in parallel:.

To download artifacts between parent-child pipelines, use needs:pipeline.

You should not download artifacts from the same ref as a running pipeline. Concurrent pipelines running on the same ref could override the artifacts.

create-artifact:
  stage: build
  script: echo 'sample artifact' > artifact.txt
  artifacts:
    paths: [artifact.txt]

child-pipeline:
  stage: test
  trigger:
    include: child.yml
    strategy: depend
  variables:
    PARENT_PIPELINE_ID: $CI_PIPELINE_ID

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

付费版 premium 才能使用

跨项目流水线的制品依赖可以使用 runner挂载本地目录来解决,即在配置runner挂载一个同步读写的本地目录,直通构建的runner docker容器中。然后将容器构建的制品复制到该目录中。
到用时再从该目录去取。 简单适用,非常适合想白嫖的同学,比如看了文章不点赞的同学。

文章来源: fizzz.blog.csdn.net,作者:拿我格子衫来,版权归原作者所有,如需转载,请联系作者。

原文链接:fizzz.blog.csdn.net/article/details/118463861

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。