运行gitlab-ci.yml时,只有在合并请求发送给master时
我目前正在GitLab和Heroku中进行项目。 我想要做的是只要我要求我的function分支的合并请求(我们称之为crud-on-spaghetti
),我想自动运行在这个分支上的testing( npm test
基本上,使用Mocha / Chai),以及成功之后,把这个crud-on-spaghetti
和master
合并,把它提交给origin/master
(在GitLab上是远程的),然后在git push heroku master
Heroku git push heroku master
(基本上把他推到Heroku的主分店,应用程序被存储)。 我已经阅读了几篇关于GitLab CI的文章,我认为这更适合我(而不是Heroku CI,因为我没有DEV和PROD实例)。
所以,到现在为止,我手动做这个。 这是我的.gitlab-ci.yml
文件( .gitlab-ci.yml
没有被提交/推送):
stages: - test - deploy test_for_illegal_bugs: stage: test script: - npm test deploy_to_dev: stage: deploy only: - origin master script: - git commit - git push origin master - git pull heroku master --rebase - git push heroku master
因此,我的问题是:我到底需要在.gitlab-ci.yml
中编写什么.gitlab-ci.yml
才能自动执行所有这些“操作”(上文)?
PS。 另一个(理论)后续问题:GitLab-CI Runner如何触发? 例如,如果我希望它触发合并请求与主,我是否only: ...
使用only: ...
in .gitlab-ci.yml
?
尝试
only: - master
origin
只是远程的一个名字。 master
是分支的名字。
跑步者是由GitLab-CI触发的一个提交被推送到存储库,所以唉不是合并请求。
您可以使用trigger
来触发pipe道,然后在integrations
从合并请求事件调用该触发器。