gitlab-plugin icon indicating copy to clipboard operation
gitlab-plugin copied to clipboard

ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job (${gitlabSourceBranch}^{commit} #timeout=10)

Open marslo opened this issue 9 years ago • 37 comments

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

Context

  • Gitlab plugin version: 1.4.5
  • Gitlab version: 9.0.5
  • Jenkins version: 2.46.1
  • Job type: Freestyle

Logs & Traces

No log shows up

Problem description

Describe your problem in a meaningful way:

  • what were you doing Following the Jenkins Job Configuration in Readme and Wiki -> Setup Example, setup Jenkins job as below:

    • Repositories:
      • Repository URL: git@<gitlab.url>:jenkins/jenkins-gitlab-test.git
      • Credentials: jenkins (works)
      • Name: origin
      • Refspec: +refs/heads/*:refs/remotes/origin/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*
    • Branches to build
      • Branch Specifier (blank for 'any'): origin/${gitlabSourceBranch}
    • Repository browser: gitlab
      • URL: http://<gitlab.url>/jenkins/jenkins-gitlab-test.git
      • Version: 9.0 Screenshot as below: gitlab-1
  • what was expected Click the Build Now button, the code should be clone to workspace successfully

  • what occurred finally Build Failed. Error:

 > 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

Other Info:

This issue is very similar with jenkins-gitlab-merge-builder-plugin issue#88

Gitlab Plugin setup in Jenkins -> Configure System: jks-3

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

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

marslo avatar Apr 19 '17 13:04 marslo

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

Job build works: jks-6

marslo avatar Apr 19 '17 13:04 marslo

Can anyone help me?

marslo avatar Apr 24 '17 13:04 marslo

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

omehegan avatar Apr 24 '17 22:04 omehegan

@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?

muselabs-co avatar Oct 15 '18 03:10 muselabs-co

@iyoucheng add gitlabSourceBranch in Parameterized Build as a string params.So you can set default value for it.

jyu213 avatar Nov 05 '18 03:11 jyu213

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

sreddy9676 avatar Jun 02 '19 16:06 sreddy9676

ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job. Finished: FAILURE

sreddy9676 avatar Jun 02 '19 16:06 sreddy9676

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

RAM237 avatar Nov 13 '19 15:11 RAM237

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.

RAM237 avatar Nov 13 '19 17:11 RAM237

using GIT_ASKPASS to set credentials GitHubUNAndPW

C:\Program Files\Git\bin\git.exe fetch --tags --force --progress -- https://github.com/arpita02-98/p.git +refs/heads/:refs/remotes/origin/ # timeout=10 C:\Program Files\Git\bin\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10 C:\Program Files\Git\bin\git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10 C:\Program Files\Git\bin\git.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

arpita02-98 avatar Mar 13 '20 06:03 arpita02-98

using GIT_ASKPASS to set credentials GitHubUNAndPW

C:\Program Files\Git\bin\git.exe fetch --tags --force --progress -- https://github.com/arpita02-98/p.git +refs/heads/:refs/remotes/origin/ # timeout=10 C:\Program Files\Git\bin\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10 C:\Program Files\Git\bin\git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10 C:\Program Files\Git\bin\git.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.

arpita02-98 avatar Mar 13 '20 06:03 arpita02-98

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.

lebuitrago avatar Aug 14 '20 16:08 lebuitrago

Probably the branch name given in wrong. FYI, Github have changed default branch name from master to main.

jerinka avatar Feb 06 '21 18:02 jerinka

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 avatar Mar 12 '21 15:03 Lindawu168

@Lindawu168, thanks for your analysis and sharing. great help.

asadbilu avatar Apr 06 '21 13:04 asadbilu

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 : )

kevinisback avatar Apr 08 '21 06:04 kevinisback

Nice one @Lindawu168, this solved the issue :)

MaNicolas avatar May 10 '21 14:05 MaNicolas

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

dharasis1993 avatar May 10 '21 17:05 dharasis1993

Probably the branch name given in wrong. FYI, Github have changed default branch name from master to main.

This is correct

ApurvDevops avatar May 13 '21 14:05 ApurvDevops

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

DevilHost069 avatar May 24 '21 07:05 DevilHost069