Jenkins error performing git command - windows

Getting the following error while trying to build:
Building in workspace F:\BuildSource\SeleniumHTTPMonitoring
> F:\soft\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> F:\soft\Git\bin\git.exe config remote.origin.url https://bitbucket.mycompany.io/scm/oi/seleniumhttpmonitoring.git # timeout=10
Fetching upstream changes from https://bitbucket.mycompany.io/scm/oi/seleniumhttpmonitoring.git
> F:\soft\Git\bin\git.exe --version # timeout=10
using .gitcredentials to set credentials
> F:\soft\Git\bin\git.exe config --local credential.username master.builder # timeout=10
> F:\soft\Git\bin\git.exe config --local credential.helper store --file=\"C:\Windows\TEMP\git1527457549107748901.credentials\" # timeout=10
> F:\soft\Git\bin\git.exe -c core.askpass=true fetch --tags --progress https://bitbucket.mycompany.io/scm/oi/seleniumhttpmonitoring.git +refs/heads/*:refs/remotes/origin/*
> F:\soft\Git\bin\git.exe config --local --remove-section credential # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://bitbucket.mycompany.io/scm/oi/seleniumhttpmonitoring.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:799)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1055)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1086)
at hudson.scm.SCM.checkout(SCM.java:485)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
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:1741)
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: Error performing git command
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1751)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1476)
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:797)
... 11 more
Caused by: org.jvnet.winp.WinpException: Failed to read environment variable table error=299 at .\envvar-cmdline.cpp:201
at org.jvnet.winp.Native.getCmdLineAndEnvVars(Native Method)
at org.jvnet.winp.WinProcess.parseCmdLineAndEnvVars(WinProcess.java:126)
at org.jvnet.winp.WinProcess.getCommandLine(WinProcess.java:102)
at hudson.util.ProcessTree$Windows$1.getArguments(ProcessTree.java:441)
at hudson.plugins.msbuild.MsBuildKillingVeto.vetoProcessKilling(MsBuildKillingVeto.java:55)
at hudson.util.ProcessTree$OSProcess.getVeto(ProcessTree.java:239)
at hudson.util.ProcessTree$Windows$1.killRecursively(ProcessTree.java:422)
at hudson.util.ProcessTree.killAll(ProcessTree.java:142)
at hudson.Proc$LocalProc.destroy(Proc.java:375)
at hudson.Proc$LocalProc.join(Proc.java:348)
at hudson.Proc.joinWithTimeout(Proc.java:164)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1736)
... 15 more
ERROR: null
Jenkins 2.7.1 is running on Windows Server 2012 R2 (the same error was occurring on Jenkins 2.7.4). I can clone the repo via git command line without any problems. When this happens I can see multiple git processes trees in task manager Screenshot and if I wait for a while I will see this in Jenkins.

The culprit was Git plugin. It started working after update.
I was using 2.5.3 version.

Related

ERROR: /var/jenkins_home/workspace/gara-bo#script/Jenkinsfile not found

I have a maven multi modules project.
I create a pipeline to clean and deploy my project.
When I run the pipeline I got the following output :
``Started by user XXXXX
Checking out git http://XXXX:9080/gara/gara-back-end.git into /var/jenkins_home/workspace/gara-bo#script to read Jenkinsfile
using credential XXXXXXXXXXX
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url http://XXXXXXX:9080/gara/gara-back-end.git # timeout=10
Fetching upstream changes from http://XXXXX:9080/gara/gara-back-end.git
> git --version # timeout=10
using GIT_ASKPASS to set credentials
> git fetch --tags --force --progress http://XXXXXX:9080/gara/gara-back-end.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision c717022003b698421698238b13e1909f555172a0 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f XXXXXXXXXXXXXXX
Commit message: "Update Jenkinsfile"
> git rev-list --no-walk 7XXXXXXXXXXXXXXXXXXXXXXX # timeout=10
ERROR: /var/jenkins_home/workspace/gara-bo#script/Jenkinsfile not found
Finished: FAILURE``
Why the project is checked out under gara-bo#script instead of gara-bo ?
On the server, I have two folders : gara-bo and gara-bo#script
``gara-bo contains : Jenkinsfile pom.xml src target WEB-INF
gara-bo#script : gara-common gara-dao gara-model gara-service gara-web JenkinsFile pom.xml``
but file in the gara-bo#script are just symbolic link because when I try to read the content of JenkinsFile under gara-bo#script it is impossible.
Do you know, how could I correct it please ?
That is because there are many other branches which didn’t contain a Jenkins file yet.
Probably it it the first time you are using Jenkins. So the Jenkins file in only in your current developing branch (E.g: YOUR_BRANCH-79).
Here don't use :origin/YOUR_BRANCH-.*, you can use :origin/YOUR_BRANCH-79.
When I create the Jenkinsfile, i Add a space in the name. So please check that the name doesn't contain a space. You have to have "Jenkinsfile", not " Jenkinsfile" or "Jenkinsfile ", etc...

Unable to Git push to a remote branch (not master) from azure pipeline

I have been trying to do a Git Push from a bash task on Azure DevOps. I was already pushing the code to the master branch without any issues.
But now I have to push it to the dev branch, and for some reason, Git Pull works but not Git Push. These are the steps I followed. I tried various versions of this actually, but nothing worked.
git config --global user.email "xxx#gmail.com"
git config --global user.name "abc"
git pull https://PAT#github.com/repo.git HEAD:dev
git add $PROXYNAME
git commit -m 'Auto-checkin of $PROXYNAME proxy to Git'
git show-ref
git push https://PAT#github.com/repo.git HEAD:dev
The above worked when the push / pull had HEAD:master at the end.
This is the error I have been getting each time.
To https://github.com/repo.git
! [rejected] HEAD -> dev (non-fast-forward)
error: failed to push some refs to 'https://***#github.com/repo.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Edited to add:
I have also tried with a checkout command - to checkout that dev branch, and no luck!
Result of git remote -v:
origin https://github.com/repo (fetch)
origin https://github.com/repo (push)
The latest error am getting is below:
error: src refspec dev does not match any
error: failed to push some refs to 'https://***#github.com/repo.git'
Could anyone please let me know what I need to do to get this working. This seems to be a recurring issue for me now :(
I believe you need to configure git remote to your correct repository.
The result of git remote -v should refer to your current directory remote association.
Start with git remote --help
Especially:
git remote set-url [--push] [] git remote
set-url --add [--push]
Here is a good tutorial on git remote.

Gradle-release plugin and SSH configuration in a Gitlab CI context

I'm using gradle-release plugin in a CI/CD context with GitLab-CI.
I have set up a public private key in GitLab to allow my pipeline to push stuff in the repo but I have an issue, I guess, with how to pass SSH info to gradle process.
In my pipeline script, I have a before_script and I do
- eval $(ssh-agent -s)
- bash -c 'ssh-add <(echo "${MY_SSH_PRIVATE_KEY}")'
MY_SSH_PRIVATE_KEY is stored in the GitLab CI variables.
Then I set my remote url with the ssh style for git repo
git remote set-url origin git#${remoteUrl}
I checkout my branch
git checkout -B ${CI_COMMIT_REF_NAME} ${CI_COMMIT_SHA}
then I call for the plugin
./gradlew release --info -Prelease.useAutomaticVersion=true
I have a an issue during the plugin process
> Failed to run [git remote update] - [Fetching origin ][Host key
> verification failed. fatal: Could not read from remote repository.
>
> Please make sure you have the correct access rights and the repository
> exists. error: Could not fetch origin ]
Do you have an idea on how to fix it?

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

Resources