简体   繁体   中英

Jenkins groovy pipeline - git checkout error

I have defined a simple Jenkins pipeline using the Groovy DSL. My intention is that it will simply checkout my git repository. However I am getting an error.

Given my groovy DSL defintion:

stage 'build'
node 
{
    git branch: '*/mybranch', credentialsId: 'my credentials', url: 'git@git.servername:pathto/myrepo.git'
}

I'm expecting the Jenkins pipeline to simply checkout my git repository.

However I'm getting the following error:

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

Can anyone help me in resolving this issue please?

The more verbose version works:

checkout([$class: 'GitSCM', branches: [[name: '*/mybranch']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'myCredentials', url: 'git@git.servername:pathto/myrepo.git']]])

However it would be nice to use the short-hand version.

Without the */ on the branch specifier works for me.

Try this:

git branch: 'mybranch', credentialsId: 'my credentials', url: 'git@git.servername:pathto/myrepo.git'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM