ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Failed to update Gitlab commit status: No (git-plugin) BuildData associated to current build
No log shows up
_Describe your problem in a meaningful way_:
git@<gitlab.url>:jenkins/jenkins-gitlab-test.gitorigin+refs/heads/*:refs/remotes/origin/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*origin/${gitlabSourceBranch}gitlabhttp://<gitlab.url>/jenkins/jenkins-gitlab-test.git9.0
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url git@<gitlab.url>:jenkins/jenkins-gitlab-test.git # timeout=10
Fetching upstream changes from git@<gitlab.url>:jenkins/jenkins-gitlab-test.git
> git --version # timeout=10
using GIT_SSH to set credentials Jenkins Slave for Gitlab Server
> git fetch --tags --progress git@<gitlab.url>:jenkins/jenkins-gitlab-test.git +refs/heads/*:refs/remotes/origin/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*
> git rev-parse refs/remotes/origin/${gitlabSourceBranch}^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/${gitlabSourceBranch}^{commit} # timeout=10
> git rev-parse origin/${gitlabSourceBranch}^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Failed to update Gitlab commit status: No (git-plugin) BuildData associated to current build
[BFA] Scanning build for known causes...
[BFA] No failure causes found
[BFA] Done. 0s
Looks like the the ${gitlabSourceBranch} cannot be found?
Here is the list of installed plugins which related with gitlab
$ ls -altrh *.jpi | grep gitlab
-rw-r--r-- 1 jenkins jenkins 7.6M Mar 6 16:36 gitlab-plugin.jpi
-rw-r--r-- 1 jenkins jenkins 1.1M Mar 6 16:42 gitlab-hook.jpi
-rw-r--r-- 1 jenkins jenkins 2.7M Mar 6 18:58 gitlab-oauth.jpi
-rw-r--r-- 1 jenkins jenkins 908K Mar 6 18:59 gitlab-logo.jpi
-rw-r--r-- 1 jenkins jenkins 2.9M Apr 19 18:13 gitlab-merge-request-jenkins.jpi
Here is the list of installed plugins which related with git
$ ls -altrh *.jpi | grep git
-rw-r--r-- 1 jenkins jenkins 40K Feb 24 00:49 git-server.jpi
-rw-r--r-- 1 jenkins jenkins 8.3K Feb 24 00:53 pipeline-github-lib.jpi
-rw-r--r-- 1 jenkins jenkins 29K Feb 24 00:53 github-organization-folder.jpi
-rw-r--r-- 1 jenkins jenkins 641K Feb 24 17:35 git-notes.jpi
-rw-r--r-- 1 jenkins jenkins 1.1M Feb 24 17:36 git-parameter.jpi
-rw-r--r-- 1 jenkins jenkins 221K Feb 24 17:36 git-tag-message.jpi
-rw-r--r-- 1 jenkins jenkins 2.1M Mar 2 22:32 github-api.jpi
-rw-r--r-- 1 jenkins jenkins 7.6M Mar 6 16:36 gitlab-plugin.jpi
-rw-r--r-- 1 jenkins jenkins 1.1M Mar 6 16:42 gitlab-hook.jpi
-rw-r--r-- 1 jenkins jenkins 2.7M Mar 6 18:58 gitlab-oauth.jpi
-rw-r--r-- 1 jenkins jenkins 908K Mar 6 18:59 gitlab-logo.jpi
-rw-r--r-- 1 jenkins jenkins 2.2M Mar 29 16:41 git.jpi
-rw-r--r-- 1 jenkins jenkins 3.7M Apr 5 22:02 git-client.jpi
-rw-r--r-- 1 jenkins jenkins 148K Apr 6 23:59 github-branch-source.jpi
-rw-r--r-- 1 jenkins jenkins 3.2M Apr 12 16:44 blueocean-github-pipeline.jpi
-rw-r--r-- 1 jenkins jenkins 1.4M Apr 12 16:44 blueocean-git-pipeline.jpi
-rw-r--r-- 1 jenkins jenkins 7.2M Apr 18 14:58 git-changelog.jpi
-rw-r--r-- 1 jenkins jenkins 3.0M Apr 19 16:25 github.jpi
-rw-r--r-- 1 jenkins jenkins 2.9M Apr 19 18:13 gitlab-merge-request-jenkins.jpi
This issue is very similar with jenkins-gitlab-merge-builder-plugin issue#88
Gitlab Plugin setup in Jenkins -> Configure System:

Gitlab Merge Request Builder setup in Jenkins -> Configure System:

In Gitlab server, user jenkins is the master of the repo:

As soon as the Branches to build -> Branch Specifier (blank for 'any'): origin/${gitlabSourceBranch} changed to */master:

Job build works:

Can anyone help me?
@Marslo gitlabSourceBranch is a parameter. If you do not add it as a parameter to your job and give it a default value, such as 'master,' then when you do a MANUAL build the parameter will be null and Git cannot clone your project. If you were to have GitLab trigger this project via a webhook on push, the correct value for gitlabSourceBranch would be passed in and set by the plugin.
@Marslo gitlabSourceBranch is a parameter. If you do not add it as a parameter to your job and give it a default value, such as 'master,' then when you do a MANUAL build the parameter will be null and Git cannot clone your project. If you were to have GitLab trigger this project via a webhook on push, the correct value for gitlabSourceBranch would be passed in and set by the plugin.
Hi, would you please tell me how to add it as a parameter?
@iyoucheng add gitlabSourceBranch in Parameterized Build as a string params.So you can set default value for it.
properties([parameters([choice(choices: ['master\nfeature-1\nfeature-2'], description: 'select a brach to build', name: 'parameterized-jobs')])])
node{
stage('SCM checkout'){
echo"pulling changes from the branch ${params.branch}"
git url:'https://github.com/javahometech/myweb', branch: "${params.branch}"
}
}
i am getting the below error
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE
From my experience it fails only on the first run of the job, on the second run checkout passes just fine!
Both times the job is executed manually via the upstream job (MultiJob plugin).
Meanwhile, the job log starts with the following on the first run:
Started by an SCM change
...
and, as OP, then I have those lines:
...
> git rev-parse origin/${CUSTOM_SHA1}^{commit} # timeout=10
> git rev-parse ${CUSTOM_SHA1}^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
And on the second time (re-run exactly the same scenario) the log begins with:
Started by upstream project "<UpstreamProjName>" build number <NNNNNN>
originally caused by:
Started by user <Firstname Lastname>
...
and instead of those rev-parse, the checkout happens as expected:
...
Seen branch in repository origin/master
Seen branch in repository origin/myBranch
Seen 2 remote branches
> git show-ref --tags -d # timeout=10
Checking out Revision 1b12693918184f8726241943cf9ac9638ef13a52 (origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 1b12693918184f8726241943cf9ac9638ef13a52
Commit message: "Merge branch 'myBranch' into 'master'"
> git rev-list --no-walk 90814700018353094ccbe40891d879240c1d691a # timeout=10
OK, my case seems to be related to this issue: https://issues.jenkins-ci.org/browse/JENKINS-17614
And W/A for it is to specify the default value of CUSTOM_SHA1 var in the job settings - appears to work fine.
using GIT_ASKPASS to set credentials GitHubUNAndPW
C:\Program Files\Git\bingit.exe fetch --tags --force --progress -- https://github.com/arpita02-98/p.git +refs/heads/:refs/remotes/origin/ # timeout=10
C:\Program Files\Git\bingit.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
C:\Program Files\Git\bingit.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
C:\Program Files\Git\bingit.exe rev-parse "origin/master^{commit}" # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Sending e-mails to:[email protected]
Finished: FAILURE
using GIT_ASKPASS to set credentials GitHubUNAndPW
C:\Program Files\Git\bingit.exe fetch --tags --force --progress -- https://github.com/arpita02-98/p.git +refs/heads/_:refs/remotes/origin/_ # timeout=10
C:\Program Files\Git\bingit.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
C:\Program Files\Git\bingit.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
C:\Program Files\Git\bingit.exe rev-parse "origin/master^{commit}" # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Sending e-mails to:[email protected]
Finished: FAILURE
how to solve the this one please help me.
I'll note this down here, in case someone else experiences my issue. I was having the same problem, and what happened in my case was that the branch that was 'supposedly' created in BitBucket, had NOT BEEN created (missed pushing), hence the error "ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job."
Once I pushed the branch to BitBucket and reran the build from within Jenkins, it worked.
Probably the branch name given in wrong. FYI, Github have changed default branch name from master to main.
Haha, I got the same error "ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job." when building a new job in Jenkins.
I found the reason, since in Jenkins new job configuration --> Source Code Management --> Git --> Branches to build -->
it is default to "/master"
where is should be "/main" instead since on my github repository my project is under "main" branch instead of "master" branch name.
Once I update it to "*/main" in Jenkins configuration branches to build, then build is successfully done.
@Lindawu168, thanks for your analysis and sharing. great help.
Haha, I got the same error "ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job." when building a new job in Jenkins.
I found the reason, since in Jenkins new job configuration --> Source Code Management --> Git --> Branches to build -->
it is default to "_/master" where is should be "_/main" instead since on my github repository my project is under "main" branch instead of "master" branch name.
Once I update it to "*/main" in Jenkins configuration branches to build, then build is successfully done.
Hi, this really solved the problem. Thank you so much : )
Nice one @Lindawu168, this solved the issue :)
Probably the branch name given in wrong. FYI, Github have changed default branch name from master to main.
This answer worked for me. I spent around 1 hour searching ways to fix the "ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job." issue. At last came across this answer and it helped. Thanks
Probably the branch name given in wrong. FYI, Github have changed default branch name from master to main.
This is correct
Haha, I got the same error "ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job." when building a new job in Jenkins.
I found the reason, since in Jenkins new job configuration --> Source Code Management --> Git --> Branches to build -->
it is default to "_/master" where is should be "_/main" instead since on my github repository my project is under "main" branch instead of "master" branch name.
Once I update it to "*/main" in Jenkins configuration branches to build, then build is successfully done.
Thanks it work by changing */master to */main as in my github there was main
Thanks it work by changing */master to */main
Most helpful comment
Probably the branch name given in wrong. FYI, Github have changed default branch name from master to main.