I'm trying to set up Jenkins on a Windows Server 2012 machine, and I'm having a lot of difficulty.
Things I've done:
id_rsa
, and id_rsa.pub
known_hosts
file for bitbucket.org using ssh.exe -T bitbucket.org
and accepting to add the host.E:
to System-wide HOME VariableC:/Windows/SysWOW64/config/systemprofile/.ssh
as well as E:/.ssh
C:/Program Files (x86)/Jenkins/jobs/MyProject/workspace/
And yet it still hangs at
Building in workspace C:\Program Files (x86)\Jenkins\jobs\MyProject\workspace
Checkout:workspace / C:\Program Files (x86)\Jenkins\jobs\MyProject\workspace - hudson.remoting.LocalChannel@13ca972
Using strategy: Default
Fetching changes from 1 remote Git repository
Fetching upstream changes from origin
I've given it about 20 minutes, so it's not a speed / size of the repo issue. If I cancel, this is what is returned:
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
hudson.plugins.git.GitException: Error performing command: C:\Program Files (x86)\Git\bin\git.exe fetch -t origin +refs/heads/*:refs/remotes/origin/*
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:780)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:739)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.fetch(CliGitAPIImpl.java:160)
at hudson.plugins.git.GitAPI.fetch(GitAPI.java:230)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:793)
at hudson.plugins.git.GitSCM.access$000(GitSCM.java:57)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:976)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:942)
at hudson.FilePath.act(FilePath.java:865)
at hudson.FilePath.act(FilePath.java:838)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:942)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1101)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1364)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:670)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:575)
at hudson.model.Run.execute(Run.java:1575)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:237)
Caused by: java.lang.InterruptedException
at java.lang.ProcessImpl.waitFor(Native Method)
at hudson.Proc$LocalProc.join(Proc.java:319)
at hudson.Launcher$ProcStarter.join(Launcher.java:360)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:769)
... 19 more
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:981)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:942)
at hudson.FilePath.act(FilePath.java:865)
at hudson.FilePath.act(FilePath.java:838)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:942)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1101)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1364)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:670)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:575)
at hudson.model.Run.execute(Run.java:1575)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:237)
I'm at my wits end here, so I appreciate all the help I can get. Here are a choice few articles which I've tried with no improvement.
Authenticate Jenkins CI for Github private repository
Permission denied (publickey) when setting up Jenkins
Hudson Git Plugin not working on windows
http://computercamp.cdwilson.us/jenkins-git-clone-via-ssh-on-windows-7-x64
Here's how I fixed a similar issue:
Msysgit installs two git.exe
. One under C:\Program Files (x86)\Git\bin
and a second one under C:\Program Files (x86)\Git\cmd
. The first one cannot be used with Jenkins. It will hang after completing it's job. The second one works perfectly.
Update your Jenkins Git settings to point to the correct cmd\git.exe
and enjoy!
This is how I solved it:
I ran the sysinternals tool psexec to spawn a CMD which is running under the LocalSystem account (same account like jenkins service is running)
PSEXEC -i -s -d CMD
In this cmd prompt I executed the same git command from the workspace directory as the hanging GIT.exe processes do. E.g.
d:\Programs\Jenkins\jobs\jobname\workspace>D:\Programs\Git\bin\git.exe fetch -t ssh+git://[email protected]:9360/data/gitpub/myRepository.git +refs/heads/:refs/remotes/origin/
Et voila: I was prompted to enter "yes" to add the SSH key to the known list of known hosts.
Just experience the freeze at 'Fetching upstream changes from origin' as well.
Running Jenkins as a service on a Windows based machine seems to (from what I have experienced) to have issues when using SSL.
Workaround Solution]
Details on Why I Choose this Solution]
I have followed other steps before with setting up the authorized host to accept the server and registering the Jenkins' key on the server to permit the connection. I've made sure I could successfully perform Git actions under my Local System account (which the Jenkins service was run under). Still, the fetch would freeze. To check that my Git and SSL was configured correctly, I even went to the initially configured Git repository in my Jenkins jobs directory and performed a successfully pull request under the local system account. It worked; therefore the keys have been setup correctly.
I forgot where I read this, but I heard issues arise when dealing with Git/SSH under a local system. With this knowledge, I played with my Git environment and altered the GIT_SSH environment variable to use plink (with a combination of Putty to remember the server key, puttygen to convert an OpenSSL key to a Putty key and pageant to remember my keys) for plink. Once I got it working with plink, I did not find it to be a useable solution. I order to correctly use plink, I had to also run pageant under my local system account to have the Jenkins service correctly negotiate SSH calls. After thinking how I would correctly setup my initial state on reboot, I didn't want to put all this effort into just getting the SSH connection working.
Instead, I decided it was easier to just run Jenkins under my local administrator account which was also configured to deal with the Git server. No having to deal with configured SSH keys for the local system account and my git actions worked fine.
Note, David Gageot's answer can apply to some. I did not have to alter any of my Git settings as when I installed Git, I choose the option Run Git from the Windows Command Prompt
which maps a path to the C:\Program Files (x86)\Git\bin\cmd\
directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With