E.A. Wilson E.A. Wilson - 3 months ago 41
Git Question

Why is Jenkins failing when fetching from git, while the command line isn't?

All of my Jenkins builds are failing at the

git fetch
line.

It's failing at
git fetch --tags --progress git@bitbucket.org:ethenwilson/whentoact.git


Started by user anonymous
Building in workspace /Users/ethen/.jenkins/workspace/Build NikNik
> git rev-parse --is-inside-work-tree
Fetching changes from the remote Git repository
> git config remote.origin.url git@bitbucket.org:ethenwilson/whentoact.git
Fetching upstream changes from git@bitbucket.org:ethenwilson/whentoact.git
> git --version
using GIT_SSH to set credentials NikNik BitBucket SSH Key
> git fetch --tags --progress git@bitbucket.org:ethenwilson/whentoact.git +refs/heads/*:refs/remotes/origin/*
FATAL: Failed to fetch from git@bitbucket.org:ethenwilson/whentoact.git
hudson.plugins.git.GitException: Failed to fetch from git@bitbucket.org:ethenwilson/whentoact.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:622)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:854)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:879)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1252)
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:1732)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:234)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@bitbucket.org:ethenwilson/whentoact.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: remote: Counting objects: 2682, done.[K
remote: Compressing objects: 0% (1/1399) [K
remote: Compressing objects: 1% (14/1399) [K
remote: Compressing objects: 2% (28/1399) [K
remote: Compressing objects: 3% (42/1399) [K
remote: Compressing objects: 4% (56/1399) [K
remote: Compressing objects: 5% (70/1399) [K
remote: Compressing objects: 6% (84/1399) [K
remote: Compressing objects: 7% (98/1399) [K
remote: Compressing objects: 8% (112/1399) [K
remote: Compressing objects: 9% (126/1399) [K
remote: Compressing objects: 10% (140/1399) [K
remote: Compressing objects: 11% (154/1399) [K
remote: Compressing objects: 12% (168/1399) [K
remote: Compressing objects: 13% (182/1399) [K
remote: Compressing objects: 14% (196/1399) [K
remote: Compressing objects: 15% (210/1399) [K
remote: Compressing objects: 16% (224/1399) [K
remote: Compressing objects: 17% (238/1399) [K
remote: Compressing objects: 18% (252/1399) [K
remote: Compressing objects: 19% (266/1399) [K
remote: Compressing objects: 20% (280/1399) [K
remote: Compressing objects: 21% (294/1399) [K
remote: Compressing objects: 22% (308/1399) [K
remote: Compressing objects: 23% (322/1399) [K
remote: Compressing objects: 24% (336/1399) [K
remote: Compressing objects: 25% (350/1399) [K
remote: Compressing objects: 26% (364/1399) [K
remote: Compressing objects: 27% (378/1399) [K
remote: Compressing objects: 28% (392/1399) [K
remote: Compressing objects: 29% (406/1399) [K
remote: Compressing objects: 30% (420/1399) [K
remote: Compressing objects: 31% (434/1399) [K
remote: Compressing objects: 32% (448/1399) [K
remote: Compressing objects: 33% (462/1399) [K
remote: Compressing objects: 34% (476/1399) [K
remote: Compressing objects: 35% (490/1399) [K
remote: Compressing objects: 36% (504/1399) [K
remote: Compressing objects: 37% (518/1399) [K
remote: Compressing objects: 38% (532/1399) [K
remote: Compressing objects: 39% (546/1399) [K
remote: Compressing objects: 40% (560/1399) [K
remote: Compressing objects: 41% (574/1399) [K
remote: Compressing objects: 42% (588/1399) [K
remote: Compressing objects: 43% (602/1399) [K
remote: Compressing objects: 44% (616/1399) [K
remote: Compressing objects: 45% (630/1399) [K
remote: Compressing objects: 46% (644/1399) [K
remote: Compressing objects: 47% (658/1399) [K
remote: Compressing objects: 48% (672/1399) [K
remote: Compressing objects: 49% (686/1399) [K
remote: Compressing objects: 50% (700/1399) [K
remote: Compressing objects: 51% (714/1399) [K
remote: Compressing objects: 52% (728/1399) [K
remote: Compressing objects: 53% (742/1399) [K
remote: Compressing objects: 54% (756/1399) [K
remote: Compressing objects: 55% (770/1399) [K
remote: Compressing objects: 56% (784/1399) [K
remote: Compressing objects: 57% (798/1399) [K
remote: Compressing objects: 58% (812/1399) [K
remote: Compressing objects: 59% (826/1399) [K
remote: Compressing objects: 60% (840/1399) [K
remote: Compressing objects: 61% (854/1399) [K
remote: Compressing objects: 62% (868/1399) [K
remote: Compressing objects: 63% (882/1399) [K
remote: Compressing objects: 64% (896/1399) [K
remote: Compressing objects: 65% (910/1399) [K
remote: Compressing objects: 66% (924/1399) [K
remote: Compressing objects: 67% (938/1399) [K
remote: Compressing objects: 68% (952/1399) [K
remote: Compressing objects: 69% (966/1399) [K
remote: Compressing objects: 70% (980/1399) [K
remote: Compressing objects: 71% (994/1399) [K
remote: Compressing objects: 72% (1008/1399) [K
remote: Compressing objects: 73% (1022/1399) [K
remote: Compressing objects: 74% (1036/1399) [K
remote: Compressing objects: 75% (1050/1399) [K
remote: Compressing objects: 76% (1064/1399) [K
remote: Compressing objects: 77% (1078/1399) [K
remote: Compressing objects: 78% (1092/1399) [K
remote: Compressing objects: 79% (1106/1399) [K
remote: Compressing objects: 80% (1120/1399) [K
remote: Compressing objects: 81% (1134/1399) [K
remote: Compressing objects: 82% (1148/1399) [K
remote: Compressing objects: 83% (1162/1399) [K
remote: Compressing objects: 84% (1176/1399) [K
remote: Compressing objects: 85% (1190/1399) [K
remote: Compressing objects: 86% (1204/1399) [K
remote: Compressing objects: 87% (1218/1399) [K
remote: Compressing objects: 88% (1232/1399) [K
remote: Compressing objects: 89% (1246/1399) [K
remote: Compressing objects: 90% (1260/1399) [K
remote: Compressing objects: 91% (1274/1399) [K
remote: Compressing objects: 92% (1288/1399) [K
remote: Compressing objects: 93% (1302/1399) [K
remote: Compressing objects: 94% (1316/1399) [K
remote: Compressing objects: 95% (1330/1399) [K
remote: Compressing objects: 96% (1344/1399) [K
remote: Compressing objects: 97% (1358/1399) [K
remote: Compressing objects: 98% (1372/1399) [K
remote: Compressing objects: 99% (1386/1399) [K
remote: Compressing objects: 99% (1398/1399) [K
remote: Compressing objects: 100% (1399/1399) [K
remote: Compressing objects: 100% (1399/1399), done.[K
Receiving objects: 0% (1/2682)
Receiving objects: 1% (27/2682)
Receiving objects: 2% (54/2682)
Receiving objects: 3% (81/2682)
Receiving objects: 4% (108/2682)
Receiving objects: 5% (135/2682)
Receiving objects: 6% (161/2682)
Receiving objects: 7% (188/2682)
Receiving objects: 8% (215/2682)
Receiving objects: 9% (242/2682)
Receiving objects: 10% (269/2682)
Receiving objects: 11% (296/2682)
Receiving objects: 12% (322/2682)
Receiving objects: 13% (349/2682)
Receiving objects: 14% (376/2682)
Receiving objects: 15% (403/2682)
Receiving objects: 16% (430/2682)
Receiving objects: 17% (456/2682)
Receiving objects: 18% (483/2682)
Receiving objects: 19% (510/2682)
Receiving objects: 20% (537/2682)
Receiving objects: 21% (564/2682)
Receiving objects: 22% (591/2682)
Receiving objects: 23% (617/2682)
Receiving objects: 24% (644/2682)
Receiving objects: 25% (671/2682)
Receiving objects: 26% (698/2682)
Receiving objects: 27% (725/2682)
Receiving objects: 28% (751/2682)
Receiving objects: 29% (778/2682)
Receiving objects: 30% (805/2682)
Receiving objects: 31% (832/2682)
Receiving objects: 32% (859/2682)
Receiving objects: 33% (886/2682)
Receiving objects: 34% (912/2682)
Receiving objects: 35% (939/2682)
Receiving objects: 36% (966/2682)
Receiving objects: 37% (993/2682)
Receiving objects: 38% (1020/2682)
Receiving objects: 39% (1046/2682)
Receiving objects: 40% (1073/2682)
Receiving objects: 41% (1100/2682)
Receiving objects: 42% (1127/2682)
Receiving objects: 43% (1154/2682)
Receiving objects: 44% (1181/2682)
Receiving objects: 45% (1207/2682)
Receiving objects: 46% (1234/2682)
Receiving objects: 47% (1261/2682)
Receiving objects: 48% (1288/2682)
Receiving objects: 49% (1315/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 50% (1341/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 51% (1368/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 52% (1395/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 53% (1422/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 54% (1449/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 55% (1476/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 56% (1502/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 57% (1529/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 58% (1556/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 59% (1583/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 60% (1610/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 61% (1637/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 62% (1663/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 63% (1690/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 64% (1717/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 65% (1744/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 66% (1771/2682), 428.00 KiB | 846.00 KiB/s
Receiving objects: 66% (1792/2682), 1.39 MiB | 1.35 MiB/s
Receiving objects: 67% (1797/2682), 1.39 MiB | 1.35 MiB/s
Receiving objects: 68% (1824/2682), 1.39 MiB | 1.35 MiB/s
Receiving objects: 69% (1851/2682), 2.23 MiB | 1.45 MiB/s
Receiving objects: 70% (1878/2682), 2.23 MiB | 1.45 MiB/s
Receiving objects: 71% (1905/2682), 2.23 MiB | 1.45 MiB/s
Receiving objects: 72% (1932/2682), 2.23 MiB | 1.45 MiB/s
Receiving objects: 73% (1958/2682), 2.23 MiB | 1.45 MiB/s
Receiving objects: 74% (1985/2682), 2.23 MiB | 1.45 MiB/s
Receiving objects: 75% (2012/2682), 2.23 MiB | 1.45 MiB/s
Receiving objects: 76% (2039/2682), 2.23 MiB | 1.45 MiB/s
Receiving objects: 76% (2042/2682), 2.23 MiB | 1.45 MiB/s
Receiving objects: 77% (2066/2682), 3.11 MiB | 1.52 MiB/s
Receiving objects: 78% (2092/2682), 4.07 MiB | 1.59 MiB/s
Corrupted MAC on input.
Disconnecting: Packet corrupt
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1325)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1186)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:87)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:257)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:620)
... 10 more


When I run
git fetch --tags --progress git@bitbucket.org:ethenwilson/whentoact.git
from the command line, it works fine, which means my SSH keys must be working.

I'm connecting to BitBucket with Jenkins with SSH verification. Jenkins gets the key from the file it's located (the default one), so I know that Jenkins is using the same key as I am when I run from the command line.

I'm using the latest build of the BitBucket and Git plugins for Jenkins. My installed Git on my Mac is version
1.8.5.2 (Apple Git-48)
.

My jenkins start command is
nohup java -jar ~/jenkins.war --httpPort=8081 --ajp13Port=8010 > /tmp/jenkins.log 2>&1 &
.

What's going wrong?

EDIT: I was wrong, I had accidentally hit an option to have the SSH Key be in the wrong place when I did that. Now, using @borrrden's suggestion, it still gives the same error. **EDIT: As @borrrden suggested, I changed my start command to
nohup java -Dorg.jenkinsci.plugins.gitclient.Git.useCLI=true -jar ~/Downloads/jenkins.war --httpPort=8081 --ajp13Port=8010 > /tmp/jenkins.log 2>&1 &
, and now I get a different crash:


Started by user anonymous
Building in workspace /Users/ethen/.jenkins/workspace/Build NikNik
> git rev-parse --is-inside-work-tree
Fetching changes from the remote Git repository
> git config remote.origin.url git@bitbucket.org:ethenwilson/whentoact.git
Fetching upstream changes from git@bitbucket.org:ethenwilson/whentoact.git
> git --version
using GIT_SSH to set credentials NikNik BitBucket SSH Key
> git fetch --tags --progress git@bitbucket.org:ethenwilson/whentoact.git +refs/heads/*:refs/remotes/origin/*
FATAL: Failed to fetch from git@bitbucket.org:ethenwilson/whentoact.git
hudson.plugins.git.GitException: Failed to fetch from git@bitbucket.org:ethenwilson/whentoact.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:622)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:854)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:879)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1252)
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:1732)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:234)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@bitbucket.org:ethenwilson/whentoact.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1406)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1194)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:87)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:265)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:620)
... 10 more

Answer

I was able to solve the problem by creating a BitBucket account exclusively for Jenkins, giving it admin permission to the repository.

I then had the repository URL be: https://JenkinsAccountUsername:JenkinsAccountPassword@bitbucket.org/OwnerOfRepositoryUsername/ProjectName.git.

Comments