【问题标题】:Trigger gitlab downstream pipeline from a upstream pipeline in a multi-project using trigger, rules and custom configuration variables使用触发器、规则和自定义配置变量从多项目中的上游管道触发 gitlab 下游管道
【发布时间】:2021-02-24 16:53:41
【问题描述】:

我有这种情况,我只想在$FLAG 变量已由.pre 阶段设置时在构建阶段运行触发器。但是,build 阶段永远不会运行。

我应该如何有条件地触发下游管道?

checkArtifactPresent:
  stage: .pre
  script:
    - >
      set +e;
      if curl -s -S -f $NEXUS_RAW_PICKER_REPOSITORY/${PRODUCT_FLAVOR}/${PRODUCT_FLAVOR}-${BUILD_TYPE}v${PICKER_TEMPLATE_TAG}.apk --output ${PRODUCT_FLAVOR}-${BUILD_TYPE}v${PICKER_TEMPLATE_TAG}.apk;
      then
        export FLAG= true;
      fi

buildArtifact:
  stage: build
  only:
   variables:
     - $FLAG
  trigger:
   project: dev/project_name
   strategy: depend

【问题讨论】:

    标签: continuous-integration devops gitlab-ci continuous-deployment gitlab-ci-runner


    【解决方案1】:

    你可以使用Gitlab web api for Triggering pipelines through API

    您可以使用触发器变量。您可以应用条件,然后触发下游作业。

    这里你可以找到一个简单的例子:

    https://docs.gitlab.com/ee/ci/triggers/#making-use-of-trigger-variables

    【讨论】:

    • 是的,我发现了,但问题是上游管道不会等待下游管道完成。好吧,我正在编写脚本以使上游管道等待。我猜在当前版本的 gitlab 中使用规则时没有功能对吗?
    猜你喜欢
    • 2021-03-16
    • 2020-09-20
    • 2020-06-15
    • 2022-07-22
    • 2020-06-14
    • 1970-01-01
    • 1970-01-01
    • 2015-08-16
    • 2022-11-15
    相关资源
    最近更新 更多