Shell类型的Runner无法工作:作业失败(系统故障):准备环境:

18

1- 环境:

  • Gitlab-CE
  • GitLab 13.2.1 (b55baf593e6)
  • GitLab Shell 13.3.0
  • GitLab Workhorse v8.37.0
  • GitLab API v4
  • Ruby 2.6.6p146
  • Rails 6.0.3.1
  • PostgreSQL 11.7
  • Debian GNU / Linux 10 服务器 (buster)

2- .gitlab-ci.yml 文件:

before_script:
  - echo "--------- STARTING WORK ------------"

job_homologacao:
   only:
     - homologation
   script:
     - cd /home/ati/
     - mkdir test
     - echo "got here"

job_producao:
   only:
     - master
   script:
     - cd /home/ati/test/
     - echo "got here"

3- 当执行 runner 时出现错误: 使用 gitlab-runner 13.2.1 (efa30e33) 在带有 Akx_BvYF shell 的运行器上运行 准备 "shell" 执行程序 使用 Shell 执行器... 准备环境 在 hermes 上运行... 错误:作业失败(系统故障):准备环境:退出状态 1。请查看https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading了解更多信息。

4- 更正尝试: 我阅读并执行了文档中包含的所有过程:

5个回答

57

我错误地编辑了位于我的主目录 /home/ati/ 内的文件.bash_logout

安装 gitlab-runner 时,Gitlab 会为其创建一个 Home 目录,在 /home/gitlab-runner/ 内。

我只需注释掉 /home/gitlab-runner/.bash_logout 文件的内容就可以让任务正常工作。


4
我将该文件重命名为.bash_logout_bkp。我发现这种方法更容易。 - Antonio
2
我希望他们(GitLab)在链接的文档中添加这一部分。 - johnny68
啊!绝对救了我的一天!谢谢! - Mahdi Salmanzadeh

40

1
我的 k8s 环境中不存在这个文件。runners helm chart :0.31。 - Gajendra D Ambi

5

首先找到 GitLab Runner 的主目录。

$ ps aux | grep gitlab-runner
/usr/bin/gitlab-runner run --working-directory /var/lib/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --syslog --user gitlab-runner

现在,检查.bash_logout是否存在。
$ ls -lah /var/lib/gitlab-runner/
total 20K
drwxr-xr-x  4 gitlab-runner root          4.0K Dec  1 02:53 .
drwxr-xr-x 42 root          root          4.0K Nov 11 03:29 ..
-rwxr--r--  1 gitlab-runner gitlab-runner   30 Dec  1 02:53 .bash_logout
drwxr-xr-x  2 gitlab-runner gitlab-runner 4.0K Dec  1 02:26 .terraform.d
drwxrwxr-x  3 gitlab-runner gitlab-runner 4.0K Nov 11 03:23 builds

最后,打开.bash_logout文件,将所有行注释掉并保存。
 $ vim /var/lib/gitlab-runner/.bash_logout
 # ~/.bash_logout: executed by bash(1) when login shell exits.

 # when leaving the console clear the screen to increase privacy

 #if [ "$SHLVL" = 1 ]; then
 #    [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
 #fi

PS:这个答案最初是由Jonathan Allen(Jonathan Allen @ sc_jallen)在GitLab Runner问题上提供的。


1
在将Ubuntu 18.04升级到20.04后,我也遇到了这个错误。 删除.bash_logout对我有用。

0

您有检查过这些吗?

  • Debian 用户应该使用 APT pinning,因为在 Debian Stretch 中有一个称为 gitlab-ci-multi-runner 的本地包,并且默认情况下,在安装 gitlab-runner 时,官方软件库中的该软件包将具有更高的优先级。

  • 此外,在安装 GitLab Runner 时,请务必禁用 SKEL:在安装软件包之前将环境变量 GITLAB_RUNNER_DISABLE_SKEL 设置为 true

有关两者的详细信息,请参见 https://docs.gitlab.com/runner/install/linux-repository.html#apt-pinning


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接