Here's how I set up gitlab-runner
for a non-root user inside a Vagrant VM (should work for non-VM machines as well):
- Check to see if the process is running for the existing user:
ps aux | grep gitlab
- If the process is running, it will look something like this after you run the previous command:
/usr/bin/gitlab-runner run --config /etc/gitlab/runner/config.toml --service gitlab-runner
- Stop the existing
gitlab-runner
systemd service:
sudo systemctl stop gitlab-runner
sudo gitlab-runner uninstall
- Reinstall the service for the new user:
sudo gitlab-runner install \
--service gitlab-runner \
--user $USER \
--working-directory /home/$USER
sudo systemctl daemon-reload
- Start the new user's
gitlab-runner
systemd service:
sudo systemctl start gitlab-runner
- To ensure the service runs on boot:
sudo systemctl enable gitlab-runner
- Check to see if the process is running for the new user:
ps aux | grep gitlab
- The new process should look something like this (I used Vagrant for this, so my user is
vagrant
):
/usr/bin/gitlab-runner run --working-directory /home/vagrant --config /home/vagrant/.config/gitlab-runner/config.toml --service gitlab-runner --user vagrant
- Run
gitlab-runner
as your new user:
gitlab-runner exec shell some_job