I have the following:
job {
scm {
git {
remote {
url(GIT_URL)
}
branch('master')
}
}
}
It works pretty well but I would like for it to set 'Check out to specific local branch' to 'master'. How is that done?
I didn't find anything in https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitSCM.java that pointed to anything that can be used but I may have missed something.
Since the accepted answer was written, support for 'Check out to specific local branch' has been added:
job {
scm {
git {
remote {
url(GIT_URL)
}
branch('master')
extensions {
localBranch 'master'
}
}
}
}
That option is currently not supported by the Job DSL, but you can use a configure block to modify the generated config XML:
job {
scm {
git {
remote {
url(GIT_URL)
}
branch('master')
configure { node ->
node / 'extensions' << 'hudson.plugins.git.extensions.impl.LocalBranch' {
localBranch('master')
}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With