"hudson.plugins.git.GitException" error, failed to fetch from git - jenkins

I am trying to pull the changes from the Git and generate the build. But every time it gives the following error. I have tried all most all the solutions provided in stack overflow. But it didn't work. My disk space is also fine.
Please help me to resolve this issue.
[EnvInject] - Loading node environment variables.
Building in workspace /Users/Shared/Jenkins/Home/workspace/Proj_name
> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from 2 remote Git repositories
> /usr/bin/git config remote.origin.url
"URL of the git repo" # timeout=10
Fetching upstream changes from "URL of the git repo"
> /usr/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials
> /usr/bin/git fetch --tags --progress
"URL of the git repo"
+refs/heads/*:refs/remotes/origin/*
ERROR: Timeout after 10 minutes
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from
"URL of the git repo"
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:888)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1155)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1186)
at hudson.scm.SCM.checkout(SCM.java:504)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
at
hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
at hudson.model.Run.execute(Run.java:1794)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git fetch --tags --progress "URL of the git repo"
+refs/heads/*:refs/remotes/origin/*" returned status code 143:
stdout:
stderr: error: git-credential-osxkeychain died of signal 15
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2002)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1721)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:72)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:405)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:886)
... 11 more
ERROR: Error fetching remote repo 'origin'
Build did not succeed and the project is configured to only push after a successful build, so no pushing will occur.

In my case I had to clean all my setup (I got an external windows agent running with winSW)
remove the workspaces corresponding to your branch (+ the temp folder)
remove the logs file for winSW (if you are using winSW)
uninstall reinstall the winSW agent (relaunch the jenkins agent / java)
ensure that all steps as been executed as admin
after the cleaning it was working fine.

Related

Jenkins Job Build Failure

After job build starts in jenkins my git-lab server's memory becomes full. Job is successful after restarting the Jenkins server.Jenkins has become too slow Sometimes Error comes with signal 9 also. Thank-you in advance. I have attached the log of the failed build.
started by user ME
Building in workspace /var/lib/jenkins/workspace/my_Project
using credential ABC
> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /usr/bin/git config remote.origin.url git#myrepo:root/My_Project.git # timeout=10
Fetching upstream changes from git#myrepo:root/My_Project.git
> /usr/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials
> /usr/bin/git fetch --tags --progress git#myrepo:root/My_Project.git +refs/heads/*:refs/remotes/origin/*
> /usr/bin/git rev-parse refs/remotes/origin/My_Project_Develop^{commit} # timeout=10
> /usr/bin/git rev-parse refs/remotes/origin/origin/My_Project_Develop^{commit} # timeout=10
Checking out Revision fbd8fcef97895366d1d08bccb22615712d1f9ef0 (refs/remotes/origin/My_Project_Develop)
> /usr/bin/git config core.sparsecheckout # timeout=10
> /usr/bin/git checkout -f fbd8fcef97895366d1d08bccb22615712d1f9ef0
Commit message: "Update features of Software."
> /usr/bin/git rev-list --no-walk fbd8fcef97895366d1d08bccb22615712d1f9ef0 # timeout=10
Checking for pre-build
Executing pre-build step
Checking if email needs to be generated
No emails were triggered.
[My_Project] $ /bin/sh -xe /tmp/jenkins6218118938138193412.sh
+ id -un
root
+ SSH_OPTS='-o StrictHostKeyChecking=no -o ConnectTimeout=5'
+ sudo git checkout My_Project_Develop
Previous HEAD position was fbd8fce... Update features of Software.
Switched to branch 'My_Project_Develop'
Your branch is behind 'origin/My_Project_Develop' by 1 commit, and can be fast-forwarded.
(use "git pull" to update your local branch)
Build step 'Execute shell' marked build as failure
Discard old builds...
#1040 is removed because status FAILURE is not to be kept
Checking for post-build
Performing post-build step
Checking if email needs to be generated
No emails were triggered.
Finished: FAILURE
You need to pull the My_Project_Develop branch, checkout is only switching to this branch. Your branch is locally behind the server.
The message is clear:
Your branch is behind 'origin/My_Project_Develop' by 1 commit, and can be fast-forwarded.
(use "git pull" to update your local branch)
Usually this is done by Jenkins. I need more info how you run this job.

Jenkins and Gitlab don't fetch code

I have a problem when i set my own project.
I start to configure my Jenkins Job, and I done this:
create credential on Jenkins for gitlab user account
create access token on gitlab and use this token in Jenkins to enable it
and this is the job configuration
but when i start a build, after10 minutes i get this error
Started by user admin
Building in workspace /Users/Shared/Jenkins/Home/workspace/xxxxxxxxx
> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /usr/bin/git config remote.origin.url https://gitlab.xxxxxxxxx.git # timeout=10
Fetching upstream changes from https://xxxxxxxx.git
> /usr/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials
> /usr/bin/git fetch --tags --progress https://xxxxxxxxxx.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://gitlab.xxxxxxx.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:825)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1092)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1123)
at hudson.scm.SCM.checkout(SCM.java:495)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1212)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:566)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:491)
at hudson.model.Run.execute(Run.java:1737)
at hudson.matrix.MatrixBuild.run(MatrixBuild.java:314)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:421)
Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git fetch --tags --progress https://xxxxxxxx.git +refs/heads/*:refs/remotes/origin/*" returned status code 143:
stdout:
stderr:
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1970)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1689)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:380)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:823)
... 11 more
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE
So... how do i solve this?
I think to solve the question. Follow this guide to add and enable jenkins user http://www.cimgf.com/2015/05/26/setting-up-jenkins-ci-on-a-mac-2/
and, at the moment, works. Thanks all
Check this option "Timeout (in minutes) for clone and fetch operations" under "Advanced Clone Behaviors"
Default time-out is 10min.

Trying to run simple JenkinsFile getting 403 forbidden error

I am trying to run a simple JenkinsFile
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'java -version'
}
}
stage('Test') {
steps {
echo 'Testing..'
}
}
}
}
As you can see there isn't much here. But I am getting a forbidden error even though I configured an account which is the owner of the repository. I posted the error as-it-is just changed the username/repository to my-account/my-repo
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/my-account/my-repo.git # timeout=10
Fetching without tags
Fetching upstream changes from https://github.com/my-account/my-repo.git
> git --version # timeout=10
using GIT_ASKPASS to set credentials Pull Request Builder
> git fetch --no-tags --progress https://github.com/my-account/my-repo.git +refs/heads/master:refs/remotes/origin/master
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.com/my-account/my-repo.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:817)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1084)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1115)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:109)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:83)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:73)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:221)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:473)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:748)
Caused by: hudson.plugins.git.GitException: Command "git fetch --no-tags --progress https://github.com/my-account/my-repo.git +refs/heads/master:refs/remotes/origin/master" returned status code 128:
stdout:
stderr: error: The requested URL returned error: 403 Forbidden while accessing https://github.com/my-account/my-repo.git/info/refs
fatal: HTTP request failed
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1924)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1643)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:352)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:815)
... 13 more
One solution is to switch to SSH when checking out the code.(Easier and always works)
If switching is not an option, then use username/password or better, generate a secret key and use that to access your repo.
Since your using it for Pull Request I'm guessing checkout scm, if this is case by default it will use https- which failed for me using 403, unfortunately the issue lied with my git being an old version 1.7/1.8 not sure exactly. Upgrading it worked like a charm :)
Hope it helps :)

Jenkins is not able to authenticate Gitlab repository

I am trying to integrate Jenkins with Gitlab.
1) Jenkins is in my private IP server.
2) I have generated the SSH key from the Gitbash and created a folder '.ssh' and pasted in the Jenkins directory.
3) give correct SSH path in Jenkins and also credentials.
4)have all the plugins.
Problem:
Jenkins is not able to authenticate Gitlab repository.
Error
Started by user jenkinadmin
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Hello World GitLab
> C:\Program Files\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> C:\Program Files\Git\bin\git.exe config remote.origin.url git#gitlab.com:dhananjaymaurya/TAA_POC.git # timeout=10
Fetching upstream changes from git#gitlab.com:dhananjaymaurya/TAA_POC.git
> C:\Program Files\Git\bin\git.exe --version # timeout=10
using GIT_ASKPASS to set credentials
> C:\Program Files\Git\bin\git.exe fetch --tags --progress git#gitlab.com:dhananjaymaurya/TAA_POC.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from git#gitlab.com:dhananjaymaurya/TAA_POC.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:797)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1051)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1082)
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:1720)
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 "C:\Program Files\Git\bin\git.exe fetch --tags --progress git#gitlab.com:dhananjaymaurya/TAA_POC.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: Host key verification failed.
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:1752)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1495)
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:795)
... 11 more
ERROR: null
Finished: FAILURE`

How to add Bitbucket repository in to jenkins?

I have a ruby on rails code in bitbucket private repository. And i have added my repository remote into jenkins as follows:
https://bitbucket.org/myuser_name/demo_app
followed by Credentials:
Kind: username and password
and i have given bitbucket username and password into it.
Before i am saving the project configuration i got no error under Repository URL. So i thought i configured source code management correct. But when i am building the project i am getting this error.
Building in workspace /var/lib/jenkins/workspace/demo_app
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://bitbucket.org/myuser_name/demo_app # timeout=10
Fetching upstream changes from https://bitbucket.org/myuser_name/demo_app
> git --version # timeout=10
using .gitcredentials to set credentials
> git config --local credential.username myuser_name # timeout=10
> git config --local credential.helper store --file=/tmp/git1159546302445779982.credentials # timeout=10
> git -c core.askpass=true fetch --tags --progress https://bitbucket.org/myuser_name/demo_app +refs/heads/*:refs/remotes/origin/*
> git config --local --remove-section credential # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://bitbucket.org/myuser_name/demo_app
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:810)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1066)
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: Command "git -c core.askpass=true fetch --tags --progress https://bitbucket.org/myuser_name/demo_app +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: error: cannot fork() for git credential-store --file=/tmp/git1159545779982.credentials get: Cannot allocate memory
error: cannot fork() for /bin/echo: Cannot allocate memory
fatal: could not read Password for 'https://myuser_name#bitbucket.org': No such device or address
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1719)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1463)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:63)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:314)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:808)
... 11 more
ERROR: null
Finished: FAILURE
So where am i going wrong?
It would be better to include your project with deployment keys instead of username/password.
To add deployment keys to your bitbucket project go to https://bitbucket.org/myuser_name/demo_app/admin/deploy-keys/ .
Add your keys to Jenkins. On the project configuration page 'Source Code Management' -> 'Credentials' -> 'Add'. Choose 'SSH Username and privat key'. Add your username 'git' and your privat key.
I do not know if today changed the way to do this, but some time ago I had to make a hook in Bitbucket to perform this task:
more info

Resources