如何编写.gitlab-ci.yml作业以仅在merge-request中运行

时间:2020-05-18 20:38:03

标签: continuous-integration gitlab gitlab-ci

当仅在合并请求中运行时,如何在.gitlab-ci.yml中正确写入作业?

test_c:
  stage: test
  script:
    - echo "This job tests something. It will only run when all jobs in the"
    - echo "build stage are complete."
  only:
    - merge_requests

此作业不在合并请求中运行,但在主服务器或开发服务器中未运行且处于粉碎状态。

2 个答案:

答案 0 :(得分:1)

您的代码正确,请先将其提交给master,然后再测试您的merge_request管道。

答案 1 :(得分:0)

Gitlab文档建议使用“规则”而不是“仅”。您可以通过执行以下操作仅完成merge_requests:

// @grant       GM_xmlhttpRequest

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

相关问题