I have a DSL script workflow described here: https://groups.google.com/forum/#!msg/jenkinsci-users/jSKwSKbaXq8/dG2mn6iyDQAJ
In this script, I have an assembly parameter called FREEBSD_SRC_URL that is passed to the workflow. Based on the different parameters in this URL, you can check another branch.
If you use git, you can still use the same method to pass the build parameter to the script, but you will need to do something a little differently. For example, you can define the BRANCH_NAME parameter in your work and do something like this in a script workflow:
String checkout_url = "https://github.com/jenkinsci/jenkins" String branch_name = "master" if (getBinding().hasVariable("CHECKOUT_URL")) { // override default URL from build parameter checkout_url = CHECKOUT_URL } if (getBinding().hasVariable("BRANCH_NAME")) { // override default branch from build parameter branch_name = BRANCH_NAME } node { // Do the git checkout git branch: "${branch_name}", url: "${checkout_url}" }
source share