Failed to install gitlab-runner: Init already exists - gitlab

I installed gitlab-runner via sudo apt install gitlab-runner, configured it according to the tutorial and it worked well.
Now I want to change the user of the gitlab-runner. So I stop the service with service gitlab-runner stop and try to change the user via
sudo gitlab-runner install --user=my-user --working-directory=/home/my-user
I get following error message:
FATAL: Failed to install gitlab-runner: Init already exists: /etc/systemd/system/gitlab-runner.service
How to proceed?

Rename the init file with
sudo mv /etc/systemd/system/gitlab-runner.service /etc/systemd/system/gitlab-runner.service.bak
and execute again
sudo gitlab-runner install --user=my-user --working-directory=/home/my-user
cleanup the backup file
sudo rm /etc/systemd/system/gitlab-runner.service.bak
Finally you can start the runner again with service gitlab-runner start.

You can simply remove this file:
rm /etc/systemd/system/gitlab-runner.service
Or:
gitlab-runner uninstall
And then install gitlab-runner again.

Related

Setting up gitlab-runner to run a shell command on a local machine upon push on specified repository

I have a repository on my gitlab server. Whenever I push to a specified branch I would like to fetch the newest version of the branch and run a script.
So far I have registered the runner in my repository under repository-sidebar -> Settings -> CI/CD -> runners
I used the provided instructions and created the provided example .gitlab-ci.yml file in the repository. It only makes use of echo commands that do not require superuser privileges on my machine.
When I push I receive a notification
"Failed pipeline for [Repositoryname]"
I followed the following instructions specified in the gitlab runner installation instructions:
# Download the binary for your system
sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
# Give it permissions to execute
sudo chmod +x /usr/local/bin/gitlab-runner
# Create a GitLab CI user
sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
# Install and run as service
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
sudo gitlab-runner start
Command to register runner
sudo gitlab-runner register --url https://git.[Address-Name].de/ --registration-token $REGISTRATION_TOKEN
Issuing gitlab-runner run results in the following error message upon a push:
Checking for jobs... received job=241221 repo_url=[URL]
WARNING: Preparation failed: getwd: stat .: permission denied job=241221 project=7 runner=[RUNNER TOKEN]
This happens when I run the runner with both sudo gitlab-runner run and just gitlab-runner run.
The problem was running "sudo gitlab-runner" as stated in the gitlab instructions, which caused the config.toml folder to be a root owned directory on the machine instead of the user owned one. registering without sudo and running without sudo worked for this

Getting docker error while using shell gitlab-runner ERRO[0000]

Hello I got this error at the installation,
when I use the command "gitlab-runner run" or "gitlab-runner start":
ERRO[0000] Docker executor: prebuilt image helpers will be loaded from /var/lib/gitlab-runner
The strange thing about it is, I using a shell runner.
I also tried on another server with no problems.
Even I tried it with a docker build and without.
I installed via
apt install gitlab-runner
Also I upgraded it and updated also. Rebuild the server (digitalocean droplet Ubuntu20.04)) and jep ... dont know what is going on.
Here also some output og the gitlab-runner:
root#Server:~# gitlab-runner verify
ERRO[0000] Docker executor: prebuilt image helpers will be loaded from /var/lib/gitlab-runner.
Running in system-mode.
Verifying runner... is alive runner=xVNzfox5
root#Server:~# gitlab-runner list
ERRO[0000] Docker executor: prebuilt image helpers will be loaded from /var/lib/gitlab-runner.
Listing configured runners ConfigFile=/etc/gitlab-runner/config.toml
test Executor=shell Token=JustAToken
URL=https://gitlab.com/
All I found about this error was about docker runner, but like I said I use a shell runner.
Thanks if someone can help.
Using this command apt-cache policy gitlab-runner, you will notice that only version 11.2.0 of gitlab-runner is available on the repositories, which is not supported by Gitlab.
Follow the official documentation to install the latest version 14.2.0.
$ sudo curl -L --output /usr/local/bin/gitlab-runner "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64"
$ sudo chmod +x /usr/local/bin/gitlab-runner
$ sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
$ # Optional sudo rm /etc/systemd/system/gitlab-runner.service
$ sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
I have the same problem since the last update of gitlab-cc.
Found this related post which helped:
Gitlab-runner without Docker
So just disable shared runners (until someone fixes this issue ;)
I was having the same problem with gitlab-runner version 13.x.
Updating to version 14.2.0 solved the problem.

How can I remove jenkins completely from linux

I have deleted jenkins all directories from different folders. But still when I access URL it is showing me jenkins login.
I want to uninstall jenkins completely. Have tried many commands from internet but still jenkins is there on server.
I have only command line access via putty so I tries whatever is possible via command to remove jenkins.
If your jenkins is running as service instead of process you should stop it first using
sudo service jenkins stop
After stopping it you can follow the normal flow of removing it using commands respective to your linux flavour
For centos it will be
sudo yum remove jenkins
For ubuntu it will
sudo apt-get remove --purge jenkins
I hope this will solve your issue.
if you are ubuntu user than try this:
sudo apt-get remove jenkins
sudo apt-get remove --auto-remove jenkins
'apt-get remove' command is use to remove package.
On Centos7,
It is important to note that while you remove jenkins using following command:
sudo yum remove jenkins
it will not remove your users and other information. For that you will have to do following:
sudo rm -r /var/lib/jenkins
First - stop Jenkins service:
sudo service jenkins stop
Next - delete:
sudo apt-get remove --purge jenkins
If you used separate server for Jenkins, some GCP or AWS - just delete this server.
Here is a video how to uninstall Jenkins from GCP Compute Engine https://youtu.be/D2HUFAc_Trw
For sentOs, it's works for me
At first stop service by sudo service jenkins stop
Than remove by sudo yum remove jenkins
I had installed Jenkins using snap and I completely forgot.
so if there is anyone out there who has tried all these steps and still gets Jenkins sign-in page try this thread.
https://stackoverflow.com/a/49695931/9854536

Install Jenkins in specific folder in RHEL

When we install jenkins, by default it installs at /var/lib directory in the RHEL machine. But I want to install jenkins in other folder or filesystem. for example /jenkins.
Before installing jenkins I changed JENKINS_HOME=/jenkins and tried installing jenkins but it wont work.
These are the steps which I followed to install Jenkins
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins
But the result is same it installs in /var/lib.
How can I install in /jenkins directory this?
Edit the /etc/sysconfig/jenkins file and change:
JENKINS_HOME = /var/lib/jenkins
to
JENKINS_HOME = /jenkins
and restart Jenkins.

How to uninstall gitlab from local ubuntu 14.04 server

Can you please help me to uninstall gitlab. i deleted the /home/gitlab but it still open up when i browse to my hostname.
Thank you.
This worked on ubuntu 16.04
sudo apt-get remove gitlab-ce
sudo rm -rf /var/opt/gitlab
--kill all process live
sudo pkill -f gitlab
-- Remove paths
sudo rm -rf /opt/gitlab
sudo rm -rf /etc/gitlab
rm -rf /var/opt/gitlab
Stop the gitlab service. Try doing.
sudo apt-get remove gitlab-ce
Then remove gitlab files from the system. Some files are in /etc directory.
Have a look at the official documentation.
uninstall Gitlab:
1- Stop the gitlab service
Command : sudo gitlab-ctl stop
2- Start commonde of service facility
command : sudo gitlab-ctl uninstall
3- Delete the package of gitlab
command : Locat gitlab
4- restart machine

Resources