'Gerrit trigger for Jenkins couldn't find any revision to build
I have trouble using Jenkins+Gerrit.
Here is what I got so far:
Gerrit Trigger configuration in Jenkins seems to be ok: When I push a new changeset, Jenkins build is launched.
I used this: Jenkins: settings for Gerrit Trigger problems to also be able to launch it "manually".
As for my configuration, I have something like this: https://stackoverflow.com/a/18347982/2248987. Branch Specifier is $GERRIT_BRANCH and Ref Spec is $GERRIT_REFSPEC
Gerrit and Git are working fines on their own. Access seems OK too.
Here is my issue. When building (gerrit triggered or manually), log output is:
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url ssh://user@host:29418/testproject # timeout=10
Fetching upstream changes from ssh://user@host:29418/testproject
> git --version # timeout=10
using GIT_SSH to set credentials
> git -c core.askpass=true fetch --tags --progress ssh://user@host:29418/testproject refs/heads/master
> git rev-parse origin/$GERRIT_BRANCH^{commit} # timeout=10
> git rev-parse $GERRIT_BRANCH^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE
I am stuck with this message, tried with empty repo, non-empty ones, and also with or without changeset "in review"
Solution 1:[1]
- Leave the 'Branches to build > Branch specifier' field blank
- Click the Advanced button, and set a custom refspec: +refs/heads/feature/my-feature:refs/remotes/origin/feature/my-feature With these settings, the plugin will correctly perform a fetch and then check out only the 'feature/my-feature' branch.
Solution 2:[2]
You could try to configure like that
- Refspec = refs/changes/:refs/changes/
- Branches to build = $GERRIT_REFSPEC
Follow the full configuration there
If you click "Build Now", Jenkins won't be able to get sources since $GERRIT_REFSPEC doesn't exist on that case.
Solution 3:[3]
Replace $GERRIT_BRANCH with $GERRIT_REFSPEC
Solution 4:[4]
After lot's of struggle and keeping eye on log,finally I got the solution.
It's just configuration mistake that we all did. Once checked check box This project is parameterized Below configuration need to be done
Here I named parameter name as branchgit
Now in Source Code Management we need to concentrate on Branches to build whose value should be only "$branchgit" as per below image

Solution 5:[5]
The following settings worked for me: Fill Refspec with $GERRIT_REFSPEC in "Advanced" section. "Branch Specifier" can be blank or any valid value
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rahul srivastav |
| Solution 2 | Community |
| Solution 3 | uncletall |
| Solution 4 | Abhishek Mishra |
| Solution 5 | Anndy Dong |

