简体   繁体   English

gitlab-ci.yml 仅在受保护的分支上运行作业

[英]gitlab-ci.yml run job only on protected branch

I want to execute a job only on the protected branches, I looked at the doc and it doesn't seem possible.我只想在受保护的分支上执行一项工作,我查看了文档,似乎不可能。 https://docs.gitlab.com/ee/ci/yaml/#onlyexcept-basic https://docs.gitlab.com/ee/ci/yaml/#onlyexcept-basic

Is there a way to do it?有没有办法做到这一点?

A branch can protect with which people can push on it or which people can merge on it.一个分支可以保护哪些人可以推动它或哪些人可以合并它。 but you can create a copy from that branch and do your job on it and after that create a request for merge it with the main branch但是您可以从该分支创建一个副本并在其上完成您的工作,然后创建一个将其与主分支合并的请求

first you can create a branch with following command首先,您可以使用以下命令创建一个分支

$ git checkout -b new-branch-name

and after you are done your task push it on the server with following command完成任务后,使用以下命令将其推送到服务器上

$ git push -u (origin-name) new-branch-name

and now you can create a merge request on the server and ask the admin to merge it.现在您可以在服务器上创建一个合并请求并要求管理员合并它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM