Shell executor fails to run jobs when .bash_logout contains clear_console

Summary

When .bash_logout contains clear command, then the shell executor fails to run anything. All jobs fail with a first command executed, long before git is called and repository checked out.

Steps to reproduce

  • Use shell executor.
  • Use default Debian's .bash_logout file in the runner's $HOME directory.

Actual behavior

Job log:

Running with gitlab-ci-multi-runner 9.5.1 (96b34cc)
  on *****-shell (*****)
Using Shell executor...
Running on ****...
ERROR: Job failed: exit status 1

Nothing happens.

Expected behavior

Run jobs as before.

Environment description

Debian Stable. gitlab-ci-multirunner is started from systemd.

/var/lib/gitlab-runner/.bash_logout contents:

# ~/.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
config.toml contents
concurrent = 1
check_interval = 0

[[runners]]
  name = "*****-shell"
  url = "https://git.*****/"
  token = "*****"
  executor = "shell"
  limit = 1
  [runners.cache]

Used GitLab Runner version

# gitlab-runner --version
Version:      9.5.1
Git revision: 96b34cc
Git branch:   9-5-stable
GO version:   go1.8.3
Built:        Wed, 04 Oct 2017 16:26:27 +0000
OS/Arch:      linux/amd64

Possible fixes

Somehow the /usr/bin/clear_console breaks the gitlab-ci-runner. Likely the /usr/bin/clear_console fails because it has no tty. Exactly same setup used to work not long time ago — certainly before latest Debian Stable was released.

The fix is simple: Remove the .bash_logout contents. However, this problem is really difficult to diagnose. The gitlab-ci-multirunner should do some check that the shell itself works and if it fails it should provide an error message to locate the problem.

Edited by Josef Kufner