Search code examples
jenkinsjenkins-workflow

Jenkins workflow job: Use parameter as branch specifier


I want to migrate our old free style dev builds, in which we use the branch name as a build parameter, to workflow builds. This works fine so far, the only thing we are really missing is the ability to use the parameter, e.g. "branch_name", as the branch specifier for the Workflow script from SCM section. On a free style build this works fine. Any ideas how this could be achieved? We don't want a dev to change the configuration all the time before starting a build.


Solution

  • Sounds like JENKINS-28447:

    When selecting the "Groovy CPS DSL from SCM" option for a worflow job, the SCM plugins do not appear to resolve build parameters or environment variables. I am using the git plugin and when I use it from other jobs I can specify a build parameter, like "BuildBranch", and use that when specifying what branch should be built

    The workaround would be to use an inline bootstrap script that calls load after checkout, as described in the tutorial.