Git plugin issue in pipeline

693 views
Skip to first unread message

Abhijith Reddy

unread,
Jun 27, 2017, 5:53:07 PM6/27/17
to Jenkins Users
Whenever i specify a branch with GitSCM i see the following issue
Couldn't find any revision to build. Verify the repository and branch configuration for this job.

Here's my Jenkinsfile

node {

    deleteDir()
    checkout([$class: 'GitSCM', branches: [[name: 'feature/my-branch]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout'],[$class: 'PruneStaleBranch']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'aaa-aaa-aaa-aaa', url: GIT_URL]]])
}


and here is the error


Checking out git ssh://g...@stash.com:7999/capt/jenkins-pipelines.git to read Jenkinsfile-pull-request
Wiping out workspace first.
Cloning the remote Git repository
 > git init /var/lib/jenkins/workspace/API/merchant-profile-and-preferences/pr-pipeline@script # timeout=10
Fetching upstream changes from ssh://g...@stash.com:7999/capt/jenkins-pipelines.git
 > git --version # timeout=10
using GIT_SSH to set credentials automated repo access
 > git fetch --tags --progress ssh://g...@stash.com:7999/capt/jenkins-pipelines.git +refs/heads/*:refs/remotes/origin/*
 > git config remote.origin.url ssh://g...@stash.com:7999/capt/jenkins-pipelines.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url ssh://g...@stash.com:7999/capt/jenkins-pipelines.git # timeout=10
Fetching upstream changes from ssh://g...@stash.com:7999/capt/jenkins-pipelines.git
using GIT_SSH to set credentials automated repo access
 > git fetch --tags --progress ssh://g...@stash.com:7999/capt/jenkins-pipelines.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse origin/develop^{commit} # timeout=10
Checking out Revision 81cbf859af011118d159c8c3a89cb796b4b1b536 (origin/develop)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 81cbf859af011118d159c8c3a89cb796b4b1b536
 > git rev-list 571b6661262fa11ce2e1088338c1f19cd1a5110d # timeout=10
First time build. Skipping changelog.
[Pipeline] node
Running on q7bld02 in /var/lib/jenkins/workspace/API/merchant-profile-and-preferences/pr-pipeline
[Pipeline] {
[Pipeline] deleteDir
[Pipeline] checkout
Cloning the remote Git repository
Cloning repository ssh://g...@stash.com:7999/api/mpp.git
 > git init /var/lib/jenkins/workspace/API/merchant-profile-and-preferences/pr-pipeline # timeout=10
Fetching upstream changes from ssh://g...@stash.com:7999/api/mpp.git
 > git --version # timeout=10
using GIT_SSH to set credentials automated repo access
 > git fetch --tags --progress ssh://g...@stash.com:7999/api/mpp.git +refs/heads/*:refs/remotes/origin/*
 > git config remote.origin.url ssh://g...@stash.com:7999/api/mpp.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url ssh://g...@stash.com:7999/api/mpp.git # timeout=10
Cleaning workspace
 > git rev-parse --verify HEAD # timeout=10
No valid HEAD. Skipping the resetting
 > git clean -fdx # timeout=10
Pruning obsolete local branches
Fetching upstream changes from ssh://g...@stash.com:7999/api/mpp.git
using GIT_SSH to set credentials automated repo access
 > git fetch --tags --progress ssh://g...@stash.com:7999/api/mpp.git +refs/heads/*:refs/remotes/origin/* --prune
 > git rev-parse feature/XMEN-512-dup​licate-contact-clean​up^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/feature/XMEN-512-dup​licate-contact-clean​up^{commit} # timeout=10
 > git rev-parse feature/XMEN-512-dup​licate-contact-clean​up^{commit} # timeout=10
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE


Mark Waite

unread,
Jun 27, 2017, 7:01:46 PM6/27/17
to Jenkins Users
I suspect you're encountering a conflict between the git plugin maintaining compatibility with old behavior, and the desire to support branch names which contain slashes.

Refer to the online help in the git plugin for alternate ways to define a branch name.  The format "word/word" is (unfortunately) ambiguous since it can be interpreted as either the local branch "feature/branch" or as a branch named "branch" on a remote named "feature".

If you'll ask for "remote/feature/branch", I think you'll get the result you want.

Refer to https://issues.jenkins-ci.org/browse/JENKINS-14026 for more history on the issue.

Mark Waite 

Mark Waite

unread,
Jun 27, 2017, 7:04:37 PM6/27/17
to Jenkins Users


On Tuesday, June 27, 2017 at 5:01:46 PM UTC-6, Mark Waite wrote:
I suspect you're encountering a conflict between the git plugin maintaining compatibility with old behavior, and the desire to support branch names which contain slashes.

Refer to the online help in the git plugin for alternate ways to define a branch name.  The format "word/word" is (unfortunately) ambiguous since it can be interpreted as either the local branch "feature/branch" or as a branch named "branch" on a remote named "feature".

If you'll ask for "remote/feature/branch", I think you'll get the result you want.


As in, "origin/feature/branch" if you're using the default remote name, "origin".

Michael Pailloncy

unread,
Jun 28, 2017, 4:52:59 PM6/28/17
to jenkins...@googlegroups.com
Can you try with something like that inside your Jenkinsfile :

node {
    deleteDir()
    checkout scm
}

Jenkins seems to be already able to retrieve your Jenkinsfile, so you don't need to give all SCM details inside it, see https://jenkins.io/doc/book/pipeline/jenkinsfile/#creating-a-jenkinsfile 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a6a95098-8538-44ac-98ee-22b10e27c223%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abhijith Reddy

unread,
Jun 29, 2017, 12:26:00 PM6/29/17
to Jenkins Users
Thanks @Mark. I switched to using refspecs and it seems to have addressed the issue. 
Reply all
Reply to author
Forward
0 new messages