Trouble with Jenkins and Git - macos

Right now I'm trying to pull a repository from bitbucket with the Git plugin, and build it within jenkins. However, whenever I do this, I get:
FATAL: Could not checkout null with start point <Starting Point>
hudson.plugins.git.GitException: Could not checkout null with start point <Starting Point>
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.checkoutBranch(CliGitAPIImpl.java:894)
at hudson.plugins.git.GitSCM$4.invoke(GitSCM.java:1229)
at hudson.plugins.git.GitSCM$4.invoke(GitSCM.java:1205)
at hudson.FilePath.act(FilePath.java:906)
at hudson.FilePath.act(FilePath.java:879)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1205)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1394)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
at hudson.model.Run.execute(Run.java:1593)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:247)
Caused by: hudson.plugins.git.GitException: Command "git checkout -f <Starting Point>" returned status code 1:
stdout:
stderr: error: unable to unlink old <File> (Permission denied)
error: unable to unlink old <File> (Permission denied)
error: unable to unlink old <File> (Permission denied)
error: unable to unlink old <File> (Permission denied)
error: unable to create file <File> (Permission denied)
error: unable to unlink old <File> (Permission denied)
I've tried manually deleting the files under the non-jenkins user in OSX, and it works, but then it will be unable to create a file.
EDIT: I actually fixed the problem by adding an "Execute shell command" step, and inserting "Git pull ", rather than using the Git plugin.

The Starting Point parameter needs to be defined
Try this instead:
git checkout -f HEAD

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

Permission denied on Git config file

I'm using Git GUI, and I was trying to create a new git repository for a folder on a remote server, which has been mapped on my Windows machine as X:/. I got following error message:
Failed to create repository
X:/blah
error: could not write config file
X:/blah/.git/config:input/output error
fatal: could not set 'core.repositoryformatversion' to '0'
I changed the permission for that folder on the remote server, but nothing changed. Any clue what was happening?
Tao

Git: Internal error: refs/remotes/origin/master is not a valid packed reference

I am attempting to clone a git repository on a Windows network drive, but the process fails. It first throws a internal error: refs/remotes/origin/master is not a valid packed reference, and then repeatedly relates that it failed to unlink an index file.
x:\code\source> git clone x:\code\repos\project.git
Cloning into 'project'...
done.
error: internal error: refs/remotes/origin/master is not a valid packed reference!
fatal: update_ref failed for ref 'HEAD': cannot update the ref 'HEAD':
Trying to write ref refs/heads/master with nonexistent object d34950c3faee46d8a7f3b8e7950b04fcc5da9d1c
Unlink of file 'project/.git/objects/pack/pack-....idx' failed. Should I try again? (y/n)
I am able to clone without issue to a local drive from a bare repo on the network drive, but am unable to clone to a network drive.
When cloning to a mapped network drive using a standard Windows command prompt, you need to preface the from path with file://.
E.g.,
git clone file://x:\code\repos\project.git
or, if there are spaces,
git clone "file://x:\my code\repos\project.git"
You cannot, however, do the same when specifying the target.
** DOESN'T WORK **
git clone file://x:\code\repos\project.git file://y:\code\source\project
Instead,
cd y:\code\source
git clone file://x:\code\repos\project.git project
For future readers who are trying to use GitExtensions and getting this error: David C's answer works for our purposes as well, and you can type in file:// before the 'Repo to clone' location name.
This error arises when the Repo to clone and destination directory are both on a local network drive.

Jenkins - java.io.IOException: Cannot run program "/usr/local/bin/bash"

I am using Jenkings in Linux_Machine_1. It have around 20 jobs(successfully running jobs)
I copied .jenkins folder to Linux_Machine_2. I started Jenkins in Linux_Machine_2.
I tried to run one of the jobs and I am getting below error:
Started by user anonymous
Building in workspace /home/portaldev/.jenkins/workspace/Trunk_Build
[Trunk_Build] $ /usr/local/bin/bash -xe /tmp/hudson1846171411013031358.sh
FATAL: command execution failed
java.io.IOException: Cannot run program "/usr/local/bin/bash" (in directory "/home/portaldev/.jenkins/workspace/Trunk_Build"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:763)
at hudson.Launcher$ProcStarter.start(Launcher.java:353)
at hudson.Launcher$ProcStarter.join(Launcher.java:360)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:91)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:60)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:804)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:160)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:586)
at hudson.model.Run.execute(Run.java:1576)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:241)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021)
... 16 more
Build step 'Execute shell' marked build as failure
An attempt to send an e-mail to empty list of recipients, ignored.
Finished: FAILURE
After I created simple job Test_Job (no build scripts) in the Linux_Machine_2. And build, even I am getting same type of error.
I tried by execute permission to all .jenkins folder
chmod +x .jenkings/
Even same out error output.
I run which bash and it gave output /bin/bash.
say ls -l /usr/local/bin/bash on machine 1 to see if there's a symbolic link from /usr/local/bin/bash to /bin/bash. if yes, then create the same link on machine 2:
cd /usr/local/bin
ln -s /bin/bash .

Git fetch github: Index-pack failed

When running the command git fetch github , I get the following error:
fatal: write error: Broken pipe93), 23.23 MiB | 635 KiB/s
fatal: index-pack failed.
I then get a "git.exe has stopped working" error message while Windows attempts to find a solution to the problem.
Running *GIT_TRACE=1 git fetch github* doesn't give any additional details.
Note: I can perform a git fetch github [branch name] directly and that works without error
When I try "Repository > Compress Database" in Git Gui, I get "Error: Command Failed". I get the same error when I try "Repository > Verify Database".
How do I get around this? It's almost like my local repo is corrupt.
System Info
*Git Bash: 1.7.4-preview20110204
Windows 7 64-bit*
Couple of options:
check if the problem persists in a new local repo (so, after re-cloning your GitHub repo)
check if raising the postBuffer size can alleviate the problem
git config --global http.postBuffer 524288000
(as mentioned in "The remote end hung up unexpectedly while git cloning")

Resources