I want to fill branchFilter automatically on Jenkins using JobDSL plugin and language.

This is the url of Jenkins Job DSL plugin:


I want to select all branches but master. To do that I have written the following lines:

  //This Build is parametrized
  parameters {
      gitParam('branch') { // https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.BuildParametersContext.gitParam
          description('Git Branch')

But when compiling it I get error that such method is not available.

Processing provided DSL script ERROR: (script, line 28) No signature of method: javaposse.jobdsl.dsl.helpers.GitParamContext.branchFilter() is applicable for argument types: (java.lang.String) values: [*] Possible solutions: tagFilter(java.lang.String)

enter image description here

Is there any workaround to do this automatically on the script or we have to fulfill that field after job has been created?


1 Answer 1


This is how I did:

gitParameter {
            // The name of the parameter.
            // The type of the list of parameters: Tag - list of all commit tags in repository - returns Tag Name Branch - list of all branch in repository - returns Branch Name Revision - list of all revision sha1 in repository followed by its author and date - returns Tag SHA1
            // In my case this is a variable pointing to the gitlab hook variable
            // A description that will be shown to the user later.
            description('Select a git the configuration you want to deploy')
            // Name of branch to look in.
            // Regex used to filter displayed branches.
            // Whatever is captured in the group will be the name used as the value of the SELECTED_BRANCH
            // This parameter is used to get tag from git.
            // Select how to sort the downloaded parameters.
            // Which value is selected, after loaded parameters.
            // If in the task are defined multiple repositories, this option specifies which the repository is taken into account on getting data.
            useRepository("<my git url>.*")
            // When this option is enabled will show a text field.
            // Specify the number of items the list will display.
            // listSize(String value)

As strange as it seems, some parameters shouldn't really be necessary, but the plugin requires them anyway, so that's why the config is verbose.

Also, pay attention that this one is gitParameter and not gitParam, yes, both exist, and they take different parameters.

For more information about the properties you can go here:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.