Un-register gitlab-runner on Ubuntu not working - amazon-ec2

I'm trying to unregister gitlab-runner on EC2 instance (Ubuntu machine) with the following command:
sudo gitlab-runner --debug unregister --token [RUNNER-TOKEN] --url [RUNNER-URL]
and I'm getting following error:
Runtime platform arch=amd64 os=linux pid=2374 revision=6fbc7474 version=13.1.1
Checking runtime mode GOOS=linux uid=0
Running in system-mode.
Dialing: tcp gitlab.com:443 ...
ERROR: Unregistering runner from GitLab forbidden runner=xv2Ng6Tc
FATAL: Failed to unregister runner

Make sure that you're using the entire SHA, not the partial one listed on the Gitlab CI runners list.
This can be found by running sudo gitlab-runner list on the machine with the runner installed.
If you've already removed the runner in the gitlab runners page, it will still be present on the gitlab-runner machine (check with the command sudo gitlab-runner list).
You can then unregister it from the config.toml using the command:
gitlab-runner verify --delete
Or manually, by running:
sudo gitlab-runner stop
sudo vi /etc/gitlab-runner/config.toml # update the runners section
sudo gitlab-runner start

For MacOS and Ubuntu
If you have already removed it from the Runners section in your project settings then you are no longer be able to unregister with command. Then what you can do is to delete them from your host as below:
gitlab-runner verify --delete
This will remove all the unregistered/removed runners from your host machine and will update config.toml file.
If you haven't removed it from Runners section in your project settings(Settings -> CI/CD -> Runners), then you can unregister it from your host like below:
gitlab-runner unregister runner_id/name
or unregister all runners,
gitlab-runner unregister --all-runners
Hope this will help to somebody. cheers !!!

I experienced the same issue when I tried to remove a runner that was removed directly from Gitlab settings of the project.
It seems that "Remove runner"'s button removes the runner from Gitlab but not from your gitlab-runner, which is absolutely fine since I don't want Gitlab to mess up to my on-premise gitlab-runner.
In order to fix that, I stopped the gitlab-runner service, removed the runner directly from the config file (it is usually located in /etc/gitlab-runner/config.toml) and started the service again.
I hope I could help you ;)

I ran into the same issue. I had to enter the right token in the config.toml file and boom, it worked: See this guide for more information: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4919. This solution is specifically for Windows, but can be applicable to Ubuntu as well.

If someone is still struggling with this like me, then here is something from docs: https://docs.gitlab.com/runner/commands/#gitlab-runner-unregister
gitlab-runner unregister --url http://gitlab.example.com/ --token <full_token_from_etc/gitlab-runner/config.toml>

Related

Jenkins - Local checkout - Enable using script console

I am encountering below error. I am able to set the property using System.setProperty("hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT", "true")
However, the issue still persists. Any pointers?
ERROR: Checkout of Git remote '<path to project folder>' aborted
because it references a local directory, which may be insecure.
You can allow local checkouts anyway by setting the system property
'hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT' to true.
I found the info I needed and propably helps you too in
https://issues.jenkins.io/browse/JENKINS-68571:
So, follow these steps:
$ sudo systemctl stop jenkins
$ sudo systemctl edit jenkins
[Service]
Environment="JAVA_OPTS=-Dhudson.model.DirectoryBrowserSupport.CSP= -Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true"
$ sudo systemctl restart jenkins
As per https://issues.jenkins.io/browse/JENKINS-68571:
it seems the System Property is read during initialization, thus changing it in Script Console does not change it.
In Script console use property on class directly:
hudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT = true
Note that neither the System Property nor the class property persist across restarts.
A persistent solution depends on how you installed / start Jenkins.
If you are running via java -jar ..., add the system property there (java -Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true -jar ...).
Or, if you installed it using your systems package manager and your system is using systemd:
$ sudo systemctl edit jenkins
[Service]
Environment="JAVA_OPTS=-Dhudson.plugins.git.GitSCM.ALLOW_LOCAL_CHECKOUT=true"
$ sudo systemctl restart jenkins

Runner is paused and will not receive any new jobs

I recently install the gitlab-ruuner in a machine and register a specific runner manually with a registration token which obtained from CI/CD Setting/runner page for my repository by :
sudo gitlab-runner register
I start it by :
sudo -s gitlab-runner start
and output :
Runtime platform arch=amd64 os=linux pid=14558 revision=f100a208 version=11.6.0
The CI pipeline stuck in pending mode and requires a active runner assigned to it. How can I activate the runner?
I solved my problem. First I forgot to do sudo gitlab-runner run and after that I changed the config.toml. Specifically I turned privilege mode to true. And finally in the runner edit page, turn on the run untagged jobs option
If your CI/CD job is pending, saying This job is stuck, because you don't have any active runners that can run this job. Go to Runners page., try restarting your gitlab runner:
$ sudo gitlab-runner stop
$ sudo gitlab-runner start
If it is still not working, then try checking, if not yet, Run untagged jobs as below for your CI/CD runner, which by default is unchecked.

install GitLab on a server running Windows 7

I need to install GitLab on a server running Windows 7, but I'm blocked at this line. The documentation doesn't really helping me. The following is from my command prompt:
C:\GitLab-Runner>gitlab-runner.exe register
Please enter gitlab-ci coordinator URL (e.g. https://gitlab.com/):
https://gitlab.com
Please enter the gitlab-ci token for this runner:
Where can I find this token?
You're attempting to install the GitLab Runner which is used to run your jobs and send the results to a GitLab which is a server. As you're talking about GitLab running at a server you have to install that and not the Runner.
But it is not supported to install GitLab on Windows, see here in the GitLab forum. They recommend to use Linux in a virtual machine for that if you want it on Windows.
In all seriousness this is something that will probably never be supported.
Nevertheless to get the needed project registration token follow these steps described here. Also there is a discussion about it on GitHub.
To create a specific Runner without having admin rights to the GitLab instance, visit the project you want to make the Runner work for in GitLab:
Go to Settings ➔ Pipelines to obtain the token
Register the Runner
Further the process of registering the GitLab Runner which is actually what you're doing is described here.

fork/exec ./debug: operation not permitted

My goal is to be able to remote debug from Atom.io. into a docker container running go in dlv debugger. This is the first problem:
Update:1. I am running Docker container on a mac, but that should not influence the code signing thing as I am running in a container, right?
Update:2. Codesignig the host, did not help.
Error:
1. root#...:/go/src/app# go get github.com/derekparker/delve/cmd/dlv
2. root#...:/go/src/app# dlv debug hello.go
could not launch process: fork/exec ./debug: operation not permitted
Then tried to
1. root#...:/go/src/app# sudo
2. bash: sudo: command not found
According Delve Issue #515
Docker has security settings preventing ptrace(2) operations by
default with in the container. Pass --security-opt seccomp:unconfined
to docker run when starting.
*confirmation of this in official docker bug tracker https://github.com/docker/docker/issues/21051
It seems to work if you start the container with --privileged. I've tried to figure out if there is a more fine-grained capability but failed.
Also I just found https://github.com/steeve/homebrew-delve which should make things easier on OSX.
Docker has security settings preventing ptrace(2)
See how i fixed it.
if using a docker-compose file to run the container then append seccomp:unconfined in the services section like below
api:
security_opt:
- seccomp:unconfined
if using docker run ...passing seccomp:unconfined works as well
Run Docker container as a command:
docker run -itd -p 2028:22 -p 2345:2345 --dns=10.236.8.8 --privileged=true --name=golang centos7-golang /usr/bin/supervisord
it works for me~

How to debug Jenkins error message "could not find a suitable ssh-agent provider"?

I'm using Jenkins on Win7 and i've installed tomcat for ssh-agent plugin. And I could clone my GitLab project via git bash via ssh.
But if I build the project by Jenkins, it always says :
[ssh-agent] Using credentials IliptonChen(APRTest)
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent] FATAL: Could not find a suitable ssh-agent provider
FATAL:[ssh-agent] Unable to start agent
The full output text is here
Did I do anything wrong?
Check the version of your ssh-agent used by Jenkins.
This bug (for linux, but could apply to Windows too) reports (10 days ago, January 2014) this very same error message:
"JENKINS-20276: Native Library Error after upgrading ssh-agent from 1.3 to 1.4".
Downgrading to 1.3 resolves the issue.
Update 2019, five years later: as commented, this should be fixed now.
ssh-agent.exe is part of a Git for Windows distribution
D:\git\git>where ssh-agent.exe
D:\prgs\gits\current\usr\bin\ssh-agent.exe
(provided path/to/git/usr/bin is first in the %PATH% used by Jenkins)
Assuming you've installed Windows Git on Windows slave, it comes with ssh-agent binary (e.g. C:\Program Files\Git\usr\bin). Try adding its path to system variable PATH.
Otherwise untick SSH Agent and choose the credentials by selecting Credentials from dropdown in Source Code Management section.
Another way is to generate personal API token (OAuth) for that GitHub user and include that along with your repository address, e.g.
git clone https://4UTHT0KEN#github.com/foo/bar
For windows, the plugin still requires Tomcat to be installed in both master and slave.
I got this error because I was using an Ubuntu image for the agent, which doesn't have SSH installed.
agent {
docker { image 'ubuntu:focal' }
}
... so the solution was as simple as installing SSH as part of the pipeline:
steps {
sh "apt-get update && apt-get install ssh -y"
// rest of your steps here...
}
In my case, the error was accompanied by an error about disk space depletion:
[ssh-agent] FATAL: Could not find a suitable ssh-agent provider
[ssh-agent] Diagnostic report
[ssh-agent] * Exec ssh-agent (binary ssh-agent on a remote machine)
[ssh-agent] hudson.AbortException: Failed to run ssh-agent: mkdtemp: private socket dir: No space left on device
So I ran docker system prune -a, which fixed it.

Resources