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}^{commit}
11:07:41 ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
I have made an investigation and saw that in property ${sha1} there was nothing. When i paste an absolute path to pull request builder like pr/341/merge instead of ${sha1} the build works. What it can be?
Git Client Plugin 1.9.0
GitHub API Plugin 1.44
sometimes this happens if "Branch Specifier" is not set properly. I corrected specifier and it worked for me.
or
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.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.
As stated here, If you want to manually build the job, in the job setting check This build is parameterized and add string parameter named
sha1
with a default value ofmaster
. When starting build give the sha1 parameter commit id you want to build or refname (eg: origin/pr/9/head).I fixed this same error message by using the
refs/heads/<branchName>
syntax in the "Branches to build - branch specifier".For example, instead of
origin/master
, I putrefs/remotes/origin/master
as the branch specifier to fix the job.(In my case, I'm not sure what caused this error message to appear, as the job was previously working fine with just
origin/master
as the branch specifier. It may have been a related update or configuration change...)Note that you can use
git show-ref
command to list references in a local repository, e.g.Also, the "?" help documentation next to 'Branch Specifier' field also supports this answer as the safest option for specifying the branch specifier to make sure the expected branch is unambiguous:
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.