运行 触发器和指定分支的脚本块

Run script-block by trigger and specified branch

我的项目有2个分支:

  1. 发展
  2. 舞台

STAGE 分支中的源代码,在 STAGE 分支中提交时通过管道构建:

deploy-stage:
  only:
    - STAGE
  before_script:
    - some scripts for build...
  script:
    - some scripts for build...

现在我想 运行 脚本块 仅用于 DEV 分支 仅通过 curl 的调用触发器 Like this

我怎样才能正确地做到这一点?

你不能通过 curl 限制你的工作异常,我的意思是一旦你在你的 DEV 阶段指定它仅由 DEV 上的更改触发,如果任何更改都会推送到 DEV 分支。

相反,另一种方法是使用基于 Curl 中的变量并在阶段示例中断言的条件:

在你的卷发中

curl --request POST \
  --form token=TOKEN \
  --form ref=dev\
  --form "variables[RUN_DEV_STAGE]=true" \  <===
  "https://gitlab.example.com/api/v4/projects/9/trigger/pipeline"

在你的 Gitlabci 中

deploy-dev:
  only:
    - dev
  script:
    - if [ -n "${RUN_DEV_STAGE}" ]; then continue else exit; fi