Jenkins Mac Slave Error - xcode

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.

Related

jenkins does not find git on mac

Jenkins building a simple hello world app fails with this command
Caused by: hudson.plugins.git.GitException: Command "git init /Users/jenkins/workspace/helloworld" returned status code 1:
stdout:
stderr: xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2430)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2360)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2356)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1916)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:988)
... 11 more
[Pipeline] }
[Pipeline] // node
[Pipeline] }
Cloning repository https://github.com/xxx/demo_qmake_hello_world.git
> git init /Users/jenkins/workspace/helloworld # timeout=10
[Pipeline] // stage
[Pipeline] End of Pipeline
ERROR: Error cloning remote repo 'origin'
Finished: FAILURE
Obviously the Jenkins java SSH connection does not find git on my mac.
But why? Yes the execution context seems to be different, not the same PATH...But adding the PATH to the node's ENV did not work. Other people had the same issues, and only got this answer, but it just does not work.
Update
There is an option on the node to specify Git Tool location. I added it like this.
Git seems to be found now. But now the permissions are unsufficient.
Caused by: java.io.IOException: Cannot run program "/usr/local/git/bin" (in directory "/Users/jenkins/workspace/helloworld"): error=13, Permission denied
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:252)
at hudson.Proc$LocalProc.<init>(Proc.java:221)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:936)
at hudson.Launcher$ProcStarter.start(Launcher.java:454)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2423)
... 15 more
Caused by: java.io.IOException: error=13, Permission denied
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 20 more
With ls -la /usr/local/git/bin I have checked the ownership.
git belonged to root, but I have changed it to jenkins.
Still this seems not enough, still get the permission error...
-rwxr-xr-x 1 jenkins wheel 5941024 Nov 8 2017 git
Update 2
The correct path in the Node's tools is /usr/local/git/bin/git. That was the problem.
which git - is the command to find git location on mac

Auto build maven project from a private bitbucket repo and jenkins

I've been working on auto-building a maven project with Jenkins.
Manually, from "start build" in Jenkins, it's working correctly, but from a bitbucket webhook :
"jenkins_url/bitbucket-hook/", after committing and pushing in my bitbucket repo, I'm getting in Jenkins's Bitbucket Hook Log this error :
FATAL: hudson.plugins.git.GitException: Command "git ls-remote -h -- https://my_username#bitbucket.org/repo.git/" returned status code 128:
stdout:
stderr: remote: Invalid username or password
fatal: Authentication failed for 'https://bitbucket.org/repo.git/'
hudson.plugins.git.GitException: Command "git ls-remote -h -- https://my_username#bitbucket.org/repo.git/" returned status code 128:
stdout:
stderr: remote: Invalid username or password
fatal: Authentication failed for 'https://bitbucket.org/repo.git/'
I'm using username and password credentials.
Wish you could help me.
I just found a solution to my own question, if someone needs it.
Just use ssh access key to connect to your bitbucket repo (not username-password credentials) :
--> connect to jenkins user by su jenkins or su -s /bin/bash jenkins
--> generate your ssh key under /var/lib/jenkins/.ssh by ssh-keygen
--> copy your private key in a jenkins global identifier
--> copy your public key in a bitbucket access key
and the build will work in both cases : manually and after a push to your
repository
(You will also need ssh publisher plugin in jenkins to put the bitbucket host id).

Unable to clone from GitHub enterprise in Jenkins

Jenkins build process fails with the following GIT error. And this seems to fail only for this GitHub Enterprise repository. If I try to do the same for GitHub repository, all ends well.
Building in workspace D:\Program Files(x86)\Jenkins\workspace\pullcodefromgithub
Cloning the remote Git repository
Cloning repository https://githubenterprise.grangeinsurance.com/hmb/sail-server.git
> git.exe init D:\Program Files (x86)\Jenkins\workspace\pullcodefromgithub # timeout=10
Fetching upstream changes from https://githubenterprise.grangeinsurance.com/hmb/sail-server.git
> git.exe --version # timeout=10
using GIT_ASKPASS to set credentials
> git.exe fetch --tags --progress https://githubenterprise.grangeinsurance.com/hmb/sail-server.git +refs/heads/*:refs/remotes/origin/*
ERROR: Timeout after 10 minutes
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git.exe fetch --tags --progress https://githubenterprise.grangeinsurance.com/hmb/sail-server.git +refs/heads/*:refs/remotes/origin/*" returned status code -1:
stdout:
stderr:
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1784)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1513)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:64)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:315)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:512)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1054)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1094)
at hudson.scm.SCM.checkout(SCM.java:495)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1278)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1728)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
ERROR: null
Finished: FAILURE
Note: This is not gitHub, but GitHub enterprise. Not sure how to fix it. No matter where I try - Mac or Windows, error is the same. Tried the same with SSH and that also fails
Started by user Ram
Building in workspace D:\Program Files (x86)\Jenkins\workspace\pullcodefromgithub
> git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git.exe config remote.origin.url https://githubenterprise.grangeinsurance.com/hmb/sail-server.git # timeout=10
Fetching upstream changes from https://githubenterprise.grangeinsurance.com/hmb/sail-server.git
> git.exe --version # timeout=10
using GIT_SSH to set credentials
> git.exe fetch --tags --progress https://githubenterprise.grangeinsurance.com/hmb/sail-server.git +refs/heads/*:refs/remotes/origin/*
ERROR: Timeout after 10 minutes
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://githubenterprise.grangeinsurance.com/hmb/sail-server.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:803)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1063)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1094)
at hudson.scm.SCM.checkout(SCM.java:495)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1278)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1728)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Caused by: hudson.plugins.git.GitException: Command "git.exe fetch --tags --progress https://githubenterprise.grangeinsurance.com/hmb/sail-server.git +refs/heads/*:refs/remotes/origin/*" returned status code -1:
stdout:
stderr:
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1784)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1513)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:64)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:315)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:801)
... 11 more
ERROR: null
Finished: FAILURE
If I try to pull the contents of the repository from terminal or command prompt or git shell, it seems to work without any issues.
I am clueless to what is going on here. Any help or advice would be greatly helpful.
Thanks
This issue happens because of jenkins using "git" in stead of "jgit". This change will bring the universe back to sanity. Here's how we do it
Manage Jenkins-> Global configuration tool
Proceed to "git" section and Tap on "Add Git" drop down button, select JGit
Save your changes
Manage Jenkins -> Browse into your project/item -> Configure
Go into the repository configuration section
Git executable - change from default to jgit
Save your changes and proceed to build
This time, build should succeed. Happy building.

Unable to connect to bitbucket using git from jenkins from tomcat installation in windows

I installed jenkins uploading the jenkins.war to my tomcat, in windows, and installed it the git plugin, I did all the procedures for the ssh key and I have been able to succesfully push and pull to my git repo in bitbucket from the cmd, but I haven't still been able to do it from jenkins, here are the weird stuff that happened to me:
I can do push and pull and execute anything from git batch but to be able to do the same from the cmd I have to open it as administrator.
The eval command doesn't work from the cmd.
I get the "returned status code 128:" exception mentioned on the jenkins git plugin installation for windows manual, but instead of getting the "fatal: The remote end hung up unexpectedly" error I get "E:\Tomcat not recognized as an internal or external command"
Here's the exception:
Fetching upstream changes from git#bitbucket.org:mycompany/myrepo.git
> C:\Program Files (x86)\Git\bin\git.exe --version # timeout=10
using GIT_SSH to set credentials SRVSYMPHONY SSH
> C:\Program Files (x86)\Git\bin\git.exe fetch --tags --progress git#bitbucket.org:mycompany/myrepo.git +refs/heads/*:refs/remotes/origin/*
FATAL: Failed to fetch from git#bitbucket.org:mycompany/myrepo.git
hudson.plugins.git.GitException: Failed to fetch from git#bitbucket.org:mycompany/myrepo.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:627)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:865)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:890)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1255)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:624)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:530)
at hudson.model.Run.execute(Run.java:1740)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:233)
Caused by: hudson.plugins.git.GitException: Command "C:\Program Files (x86)\Git\bin\git.exe fetch --tags --progress git#bitbucket.org:mycompany/myrepo.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: "E:\Tomcat" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.
fatal: Could not read from remote repository.
Do you know whats happening to me?
Thanks
In order to be able to connect to my private repo in bitbicket I had to add the password to the url this way:
https://<user>:<pass>#bitbucket.org/<user>/<project>.git
The answer was in this question:
Using Jenkins with a private BitBucket Git repository
Thanks

Jenkins/Github Error cloning remote repo 'origin' : Could not clone

I need some help with an authentication issue I have encountered with Github/Jenkins.
Setup is as follows:
Jenkins master is on windows
Slave is running on OSX
Jenkins can communicate fine with the slave
When trying to pull from our private git repo we see the following error, this error is not on either the master or other linux slaves and clones fine in OSX terminal.
Started by user xxxxxxxxxxxx
[EnvInject] - Loading node environment variables.
Building remotely on MAC01 in workspace /var/jenkins/workspace/xxxxxxxxxxxx
Checkout:NativeiOSSlots / /var/jenkins/workspace/xxxxxxxxxxxxx - hudson.remoting.Channel#166d8eb:MAC01
Using strategy: Default
Last Built Revision: Revision 7232678c31bf2c6f3c4bd5a66b349edf9288440c (origin/HEAD, origin/master)
Cloning the remote Git repository
Cloning repository <repo url>
git --version
git version 1.8.3.1
ERROR: Error cloning remote repo 'origin' : Could not clone <repo url>
hudson.plugins.git.GitException: Could not clone <repo url>
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:226)
at org.jenkinsci.plugins.gitclient.AbstractGitAPIImpl.clone(AbstractGitAPIImpl.java:57)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.clone(CliGitAPIImpl.java:33)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1012)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:948)
at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2387)
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:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:680)
Caused by: hudson.plugins.git.GitException: Command "/Applications/GitHub.app/Contents/Resources/git/bin/git clone --progress -o origin <repo url> /var/jenkins/workspace/xxxxxxxxxx" returned status code 128:
stdout: Cloning into '/var/jenkins/workspace/xxxxxxxxxx'...
stderr: remote: Repository not found.
fatal: Authentication failed for '<repo url>'
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:790)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$100(CliGitAPIImpl.java:33)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:224)
... 14 more
Any Ideas?
I was facing same problem. Jenkin was not able to clone my git repo to local PC.
Solution:
Start services.msc
goto Jenkins service and open it's property
goto Logon tab and and give your a/c userName and password.
restart the service.
These steps solved my problem, as I have given my enterprise login and password in there.
Most likely the user that the Jenkins slave runs as on your Mac isn't properly set up for github (doesn't have the proper certificate). On my Mac slave that's the user named jenkins. Log in as that user on your slave and see if you can do:
ssh -T git#github.com
If that's not working, make sure you have the proper certificate installed and that the machine can see the outside world.
Does it really clone fine from the terminal when run as the user running jenkins ?
You probably haven't set up your SSH access properly. See this: Could not clone repository
I also had this issue. I ended up having to downgrade my Git Client plugin to 1.6.4. When I was running 1.8.0 I got this error for every repo I tried to clone. As soon as I rolled it back, it all started to work.

Resources