gitlab 多工程的pipeline

多个gitlab项目能否关联起来跑pipeline呢?gitlab已经实现了。可以在一个pipeline里面去触发其他项目的pipeline。
但是目前看起来这个功能好像并不能满足企业实际项目开发的实际需求。
因此:

  1. 学习gitlab目前多工程的pipeline能够提供的功能
  2. 梳理实际项目的需求
  3. gitlab能够满足的功能就使用目前的功能,不能满足的就需要使用api的方式自己实现啦。
    文献:
    https://www.kancloud.cn/apachecn/gitlab-doc-zh/1948835
    https://docs.gitlab.com/ee/ci/pipelines/multi_project_pipelines.html

遗留问题

  1. 是否可以触发mr
  2. 是否可以等待子流水线运行结束,也就是控制串型或者并行 【好像可以使用 strategy: depend 】

gitlab目前的功能

  1. 触发其他项目的pipeline,指定分支的pipeline
  2. 传递或者不传递环境变量到其他项目的pipeline中
  3. 等待其他pipeline运行结束

两种方法

  1. 在.gitlab-ci.yml中定义
  2. 使用api

.gitlab-ci.yml

rspec:
  stage: test
  script: bundle exec rspec

staging:
  variables:
    ENVIRONMENT: staging
  stage: deploy
  trigger: my/deployment
rspec:
  stage: test
  script: bundle exec rspec

staging:
  stage: deploy
  trigger:
  	project: downstream/project
  	branch: $CI_COMMIT_REF_NAME
variables:
  MY_GLOBAL_VAR: value

trigger-downstream:
  inherit:
    variables: false
  variables:
    MY_LOCAL_VAR: value
  trigger: my/project
trigger_job:
  trigger:
    project: my/project
    strategy: depend

api

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐