Gitlab-Runner is changing user running shell scripts
Summary
I've installed Gitlab-runner and configured to use root to execute shell scripts. However, the user is changed back to gitlab-runner without no reason.
Steps to reproduce
1- Install gitlab-runner:
$ gitlab-runner install --user root --working-directory /home/gitlab-runner
2- Execute a pipeline using shell script that needs root
permissions.
Actual behavior
Failed to execute command:
$ whoami
gitlab-runner
$ systemctl stop httpd && sleep 1
Failed to stop httpd.service: Interactive authentication required.
See system logs and 'systemctl status httpd.service' for details.
Expected behavior
Expected output:
$ whoami
root
$ systemctl stop httpd && sleep 1
Relevant logs and/or screenshots
See above
Environment description
Server: CentOS 7 Kernel: 3.10.0-957.5.1.el7.x86_64
Used GitLab Runner version
Gitlab Version: 12.0.3-ce.0.el7 @gitlab_gitlab-ce Gitlab Runner: 12.0.2-1 @runner_gitlab-runner