I'm currently using Jenkins on Windows 10, and using git as version control system.
Although I provided correct repository URL and credential, I cannot use jenkins with error below.
Failed to connect to repository : Command "git.exe ls-remote -h REPOSITORY_URL HEAD" returned status code 128:
stdout:
stderr: git#URL: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Credential and URL doesn't seems wrong, since this build success previously with same credential. The only change after successful build was one line in build script.
git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
After I success with this script, git setting keeps failed. Is there any problem with that line? And how can I fix it?
EDIT
Problem solved! For anyone who has same problem, it was problem with the system user! Since ssh key stores in each user space, jenkins cannot detect where the ssh key located. Therefore, go to 'service' in windows, and change user of jenkins service to the user who has correct ssh key. It solved my problem!
Seems there is some problem in Jenkins.
It cannot locate OpenSSH folder in System32, and so that I cannot get log with it.
That would explain why the main Jenkins controller (aka "master" in old terminology) cannot contact the Git repository (assuming an SSH URL here, with technical remote user account "git")
Try and remove that git configuration to see if the error persists: Git should fall back to its own ssh.exe, packaged with Git For Windows.
As noted by the OP, this only works if said Jenkins is run as a user account, not as the system account.
Only then will it be able to access the %USERPROFILE%\.ssh folder.
Tried with the configure option, not able to find the tools
configuration option and the git executable section. Seems like it
occurs after a successful build only. Please help.
Here's the output I receive after building the project on the console output section:
Building in workspace C:\Users\Anishas\.jenkins\workspace\Sample123
Cloning the remote Git repository
Cloning repository https://github.com/AnishaSalunkhe/HelloWorld.git
> C:\Users\Anishas\git init C:\Users\Anishas\.jenkins\workspace\Sample123 # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init C:\Users\Anishas\.jenkins\workspace\Sample123
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:656)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:463)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1057)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1097)
at hudson.scm.SCM.checkout(SCM.java:485)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Caused by: hudson.plugins.git.GitException: Error performing command: C:\Users\Anishas\git init C:\Users\Anishas\.jenkins\workspace\Sample123
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1726)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1695)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1691)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1321)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:654)
... 12 more
Caused by: java.io.IOException: Cannot run program "C:\Users\Anishas\git" (in directory "C:\Users\Anishas\.jenkins\workspace\Sample123"): CreateProcess error=5, Access is denied
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:240)
at hudson.Proc$LocalProc.<init>(Proc.java:212)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:815)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1715)
... 16 more
Caused by: java.io.IOException: CreateProcess error=5, Access is denied
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 22 more
ERROR: null
Finished: FAILURE
This wasted so much time on my Jenkins Windows slave.
I knew git was in the path because I executed "where git" in the build job's batch command.
where git
C:\Program Files (x86)\Git\cmd\git.exe
Apparently the Jenkins Git Plugin executes ** before ** the environment is inherited.
SET YOUR SLAVE's PATH to Git ( Just DO IT !! )
1) Go to your Windows slave configuration
Manage Jenkins > Manage Nodes
2) Select your slave configuration
3) Check Tool Locations under Node Properties
4) Enter complete path to git executable including git.exe
[x] Tool Locations
Name: (GIT) git
Home: C:\Program Files (x86)\Git\cmd\git.exe
See screenshot:
Go to Manage Jenkins / Global Tool Configuration and set Path to Git executable:
set the path to git.exe and not only to the directory of the git file in both the locations of tool configurations.
Check for below command in Jenkins Server in linux Env:
`whereis git`
you will get the path like /usr/bin/git
Place it in Manage jenkin>Global Tool Configuration> under git path mention /usr/bin/git
Rerun job again
Sometimes this error occurs when disk space is less. so do check the space of your machine where jenkins is hosted. :)
If anyone is using Jenkins with freshly installed Xcode, you'll need to agree to the license using sudo xcodebuild -license or agree through UI.
There can be multiple reasons for that
Check the Permission of the Folder or the Worker Node, In my case 3rd one was the issue because of not providing permissions to the users and groups. As a result you may need to do
sudo chown -R user:group folderName
Check you have configured the SSH Key, if you are using Private Repo from GitHub.
Path Must be provided inside Jenkins Global Configuration of Default Git
In my case,
I have installed git on my slave server. Download-git
Run cmd command
where git
and update your git path with exe file like below in Jenkins node configuration.
C:\Program Files\Git\cmd\git.exe
Go to your Windows slave configuration, Manage Jenkins > Manage Nodes > Select your slave > configure
Check "Tool Locations" under "Node Properties" and give the full path what you got from 'where git' command and save.
yes I have faced the same issue on the Linux ec2 instance but I fixed it through
First of all on your server run the below command, and this command will return to you
$ which git
this command will return to you the actual path of the git, where your git is installed like that /usr/bin/git copy this path.
open your Jenkins > go to manage Jenkins >Global tool configuration > paste the in this field "Path to Git executable
Windows:
1. Install git in windows machine
2. The git.exe path is C:\Program Files\Git\cmd\git.exe (by default, unless you change during installation)
3.Now need to show the path of git.exe in Jenkins git plugin tool
a)manage Jenkins>Global Tool Configuration>Git
b)Add git : name: anything and Path:C:\Program Files\Git\cmd\git.exe
4. Then build for clone. Should be ok
Linux CentOS7:
Same error message I got and after installation git in same machine were Jenkins installed, it is solved.
yum install git
Then you need to follow below steps. Hope so this may be useful for you to resolve your problem.
If your master is linux machine and slave is windows machine...
Pre-Requisites:
your slave machine should have same java version(jdk 1.8).
Git should be installed on your slave machine.
Steps to follow:
Go to your Windows slave configuration Manage Jenkins > Manage Nodes
Select your slave configuration
Check Tool Locations under Node Properties
Enter complete path to git executable including git.exe
Tool Locations
Name: (GIT) git
Home: C:\Program Files (x86)\Git\cmd\git.exe
See screenshot:
1) Make sure the git.exe has executable permissions.
2) Make sure git is configured correctly to refer in Global Tool configurations and also on the Jenkins agent (windows in your case) where you running the job, environment variable for git.exe executable is set correctly
have this problem after my company move to 2FA (2 factory authentication) at GitHub
in the Jenkins I get in credential this
to fix it
I create a personal access token in Github from here
2)after that i get to the same place in the jenkins when the errors ->Credential->add ->jenkins
and get as you see in the picture down
username= what you want name
password = token that you get
Upgrading all plugins and Jenkins to 2.332.1 solved for me
This answer may sound like a joke, but it resolved the exact error message we were getting for only 1 pipeline:
Check if the pipeline has a parameter with no name value.
Don't forget to Add your deploy key credentials (the deploy key attached to the github project) in jenkins (http://yourjenkinsurl:8080/credentials/)
I have a Jenkins Server (Linux) with connection with Bitbucket.
For iOS projects, I needed to create a connection to a Mac OS slave, but in the slave, I can't connect to the Bitbucket repo and make the clone.
ERROR: Error cloning remote repo 'origin' : Could not clone
git#bitbucket.org:nameProjectGit
hudson.plugins.git.GitException: Could not clone git#bitbucket.org:nameProjectGit
at hudson.plugins.git.GitAPI.clone(GitAPI.java:268)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1122)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1064)
at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2196)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at hudson.remoting.Engine$1$1.run(Engine.java:60)
at java.lang.Thread.run(Thread.java:680)
Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin git#bitbucket.org:mauredo/snapandsell_ios.git /Users/usertest/dev/jenkins/workspace/SnapAndSell_iOS" returned status code 128:
stdout: Cloning into '/Users/usertest/dev/jenkins/workspace/ProjectName'...
stderr: ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
Host key verification failed.
fatal: The remote end hung up unexpectedly
...
My project's in the master compile correctly. If I make the push from the terminal in the slave, it succeeds.
Any idea how to solve this?
Looks like the problem is with your GIT plugin, which is missing an SSH component -
namely ssh-askpass .
Either disable the GIT Plugin or install the missing SSH component.
I'm just starting to look at Jenkins CI on my Windows 7 machine.
I thought for a first test I would create a git repo on my localhost which is aliased to
http://tests.local/jenkins/local
I setup a job in Jenkins, selected Git under source code management and added http://tests.local/jenkins/local.git as the Repository URL
When the job runs it fails with the error
ERROR: Error cloning remote repo 'origin' : Could not clone http://tests.local/jenkins/local.git
Is this a git issue or a Jenkins issue and how can I fix it?
Thanks
Have you run git update-server-info in your repo? This is needed if you want to clone/fetch via http. Run git help update-server-info or see online documentation here for more details.
I installed Jenkins CI from homebrew (brew install jenkins). So, it runs under my own user. Everything works fine except for SSH access to my Git repository. I do not want to create a separate user (e.g. jenkins) to run Jenkins and create separate SSH keys for it. I just want to use my own SSH keys. Accessing my remote git repo on the command-line works fine with my ssh keys, but in Jenkins it does not work. It gives a 'Permission denied (publickey)' error (username and project are obfuscated (<user> and <project>)):
Started by user anonymous
Checkout:workspace / /Users/<user>/.jenkins/jobs/<project>_run_tests/workspace - hudson.remoting.LocalChannel#456d3d51
Using strategy: Default
Last Built Revision: Revision 093f1641f26632afd1a74c14276ec544356c1d08 (origin/dev)
Checkout:workspace / /Users/<user>/.jenkins/jobs/<project>_run_tests/workspace - hudson.remoting.LocalChannel#456d3d51
Fetching changes from 1 remote Git repository
Fetching upstream changes from ssh://git#bitbucket.org/<user>/<project>.git
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
ERROR: (Underlying report) : Error performing command: /usr/local/bin/git fetch -t ssh://git#bitbucket.org/<user>/<project>.git +refs/heads/*:refs/remotes/origin/*
Command "/usr/local/bin/git fetch -t ssh://git#bitbucket.org/<user>/<project>.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: Permission denied (publickey).
fatal: The remote end hung up unexpectedly
ERROR: Could not fetch from any repository
FATAL: Could not fetch from any repository
hudson.plugins.git.GitException: Could not fetch from any repository
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1012)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:972)
at hudson.FilePath.act(FilePath.java:783)
at hudson.FilePath.act(FilePath.java:765)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:972)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1195)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:568)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:457)
at hudson.model.Run.run(Run.java:1404)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:230)
It seems it is not using my ssh keys to connect to the git server. I tried adding a UserName key to the jenkins launchagent plist, did a restart, but no effect.
How can I make jenkins use my SSH keys to connect to my remote git repo?
I do not know how homebrew sets up Jenkins, but apparently it is running in a context where it has no access to your ssh agent and your ssh key is passphrase-protected.
When you run it in a Terminal window, you have SSH_AUTH_SOCK variable in your environment which ssh client uses to authenticate. If you cannot use the ssh agent, you need to remove the passphrase from the ssh key.