How to clone a git repo with a different branch than master on Jenkinsfile

29 views
Skip to first unread message

Mario Rodriguez

unread,
Oct 26, 2016, 7:50:56 PM10/26/16
to Jenkins Users
Hi, I have a very simple Jenkinsfile pipeline that uses "checkout scm" but I'm looking for a way to specify this command to use a different branch than master.

any ideas ?

thanks

Sverre Moe

unread,
Oct 27, 2016, 3:18:40 AM10/27/16
to Jenkins Users
Snippet generator => checkout: General SCM

Sverre Moe

unread,
Oct 27, 2016, 3:34:28 AM10/27/16
to Jenkins Users
One more thing:
You do not need to set all parameters on the new checkout.
Get common parameters through the available scm variable.
Getting the URL to git repository:
    final def repositories = scm.getRepositories()
   
final def scmRepo = repositories.first()
   
final def URI = scmRepo.getURIs().first().toString()
Then set
userRemoteConfigs: [[url: URI]]

Reply all
Reply to author
Forward
0 new messages