在 git 推送后自动将 gitlab-运行ner 设置为 运行?

Setup gitlab-runner to run automatically after git push?

当我 git 推送时,我必须转到配置了 gitlab-runner 的服务器,然后在终端 "sudo gitlab-runner run" 或 "gitlab-runner run" 中输入。然后管道将启动。而且我必须一直在运行时平台中。这违背了管道的意义。

它曾经工作,所以当我 git 按下时,管道会自动启动,我根本不需要输入命令。那么有没有办法设置它?

gitlab documentation 很清楚:

GitLab offers a continuous integration service. For each commit or push to trigger your CI pipeline, you must:

  • Add a .gitlab-ci.yml file to your repository’s root directory.
  • Ensure your project is configured to use a Runner.

.gitlab-ci.yml部分

您需要在存储库的根目录中 create 一个名为 .gitlab-ci.yml 的文件。脚本部分取决于你想在工作中做什么。

转轮部分

你需要install and configure亚军。

最简单的就是用shared runner

有以下两种方法可以实现。

  1. nohup gitlab-runner run & 将使您的运行程序 运行 保持为用户进程,并使用默认为 /home/<user>/.gitlab-runner/config.toml 的配置文件(参见 man nohup
  2. sudo systemctl start gitlab-runner 将作为服务启动,并使用默认为 /etc/gitlab-runner/config.toml 的配置文件(参见 man systemctl

在这两种情况下,您都可以注销并且跑步者将保持活动状态。