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 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.