I faced error when I try to build my Gitlab project in Jenkins.
What I tried
- Set the system environment as Setup your environment variables for Git Plugin Jenkins
- Under “git” change “Path to Git executable” to GIT_FOLDER\cmd\git.cmd (NOT GIT_FOLDER\bin\git.exe)
Using PsExec.exe to let the “Local System account” accessed by Jenkins server to have SSH keys or known_hosts set up and verify via
"GIT_FOLDER\bin\ssh.exe" -T [email protected]
Even success to fetch via the same command in the
"C:\Program Files (x86)\Git\bin\sh.exe" -login -i window
Fill in the Gitlab host url and API Token for Jenkins account in Gitlab server
- Create credential with ssh key with no passphrase and selected in project credential
Jenkins Build Error Log
(git_repository.git represents my git repository url)
Started by user Jenkins
Building in workspace C:\Program Files (x86)\Jenkins\jobs\MyApp-Test\workspace
C:\Program Files (x86)\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
C:\Program Files (x86)\Git\bin\git.exe config remote.origin.url git_repository.git # timeout=10
Fetching upstream changes from git_repository.git
C:\Program Files (x86)\Git\bin\git.exe --version # timeout=10
using GIT_SSH to set credentials
C:\Program Files (x86)\Git\bin\git.exe -c core.askpass=true fetch --tags --progress git_repository.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 git_repository.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:735)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:983)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1016)
at hudson.scm.SCM.checkout(SCM.java:485)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1282)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:610)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:532)
at hudson.model.Run.execute(Run.java:1741)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:381)
Caused by: hudson.plugins.git.GitException: Command "C:\Program Files (x86)\Git\bin\git.exe -c core.askpass=true fetch --tags --progress git_repository.git +refs/heads/*:refs/remotes/origin/*" returned status code -1:
stdout:
stderr:
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1591)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1379)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:86)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:324)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:733)
... 11 more
ERROR: Error fetching remote repo 'origin'