Stuart Stuart - 1 month ago 25
Groovy Question

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?

Answer

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.