Yesterday my pullrequest jobs failed with the following output:
11:07:41 > git rev-parse origin/${sha1}^{commit}
11:07:41 > git rev-parse ${sha1}^{co
I spent a long time on this. The above comment "if I leave this field blank" worked like a charm. In SCM:
1) select Git
2) Name: origin
3) Refspec: +refs/pull/*:refs/remotes/origin/pr/*
4) Branches to build : leave blank
This solved the above error.
Sometimes the branch name specified in the jenkins and repository are different. In my case jenkins set Master as a default branch in jenkins. But my actual branch is main. Which costs me over two hours of my time to identify. I didn't change it as jenkins sets it default. Errormain But it is the error. So first verify the branch name in your repository and the branch name in jenkins if you get this error.
sometimes this happens if "Branch Specifier" is not set properly. I corrected specifier and it worked for me.
*/release/release4.5.0
or
*/feature/myfeature
I had the same problem. TIn my case, the cause was that I used a github repository that was a mirror of an svn repository (because svn is not properly supported by SonarCloud). The default in Jenkins was */master
. The solution (found by Gavin McDonald of Apache INFRA) was to use */trunk
. Another problem is the ".git" in the URL, that should not be used.
I was facing this same error recently and none of the above were working for me since I wanted Jenkins to checkout a specific branch of my code. The branch name was set to ${BRANCH} which was a Jenkins parameter I created on same job.
If I used some other branch, it worked fine. Took me a long time to debug since it worked everywhere else. I could clone the repo and checkout that branch myself locally without issues. But only Jenkins seemed to be reporting this error.
Finally after a lot of investigation, I realised the default value that I set to the BRANCH parameter in this Jenkins job was copied by me from an earlier run of the same job from the Parameters section. Looks like a hidden special character gets added if we copy from that section and that is why even though it looked to be the same branch I wanted to checkout in the Jenkins logs, it was somehow having an additional hidden character and hence was failing each time. I deleted the default value from that parameter and re-typed that value as the default manually in the Job configuration and it worked fine after that.
After lots of research and head breaking. I was receiving the same error and I found out that this error also occurs if you are using a different git path. Make sure you have the correct path. For ex: I replaced C:\Program Files\Git\git-bash.exe with C:\Program Files\Git\bin\git.exe and this resolved the issue.