There is not a great way in Jenkins databinding to handle String[]-valued properties. The general best practice is to make the property name as understood by Stapler (data binding) match the property name as understood by XStream (serial form), and for the type of both to be natural (a collection of some kind rather than a text blob). This makes for more consistent and predictable interaction with ways of defining job configuration other than the web UI. This tends to matter for the Workflow plugins (Describable objects instantiated as part of Step configuration from the Groovy DSL); Job DSL plugin; YAML Project plugin; etc.

      This commit gives an example of how you can make these align, even using the standard textarea.jelly control. The trick is to override Descriptor.newInstance. This is awkward though, and prevents you from using automatic databinding for other properties of the same class.

      It would be preferable to have a standard form control dedicated to representing a list of strings, probably rendered as a textarea (split on newlines and whitespace trimmed), though a series of textboxes with Add/Remove buttons is also an option. The representation created by buildFormTree should be a JSON array, which I believe Stapler already knows how to bind to Java arrays and/or lists; and FormChecker would ideally let you use a collection type in @QueryParameter for doCheck* methods as well. (Using a Set<String> as the property type is dubious, because duplicates will be silently deleted when the form is saved. Perhaps better to use a FormValidation warning to alert the user if duplicates are unwanted for the particular property.)

          [JENKINS-27901] Standard form control for string collections

          Jesse Glick created issue -
          Jesse Glick made changes -
          Link New: This issue is blocking JENKINS-26143 [ JENKINS-26143 ]
          Jesse Glick made changes -
          Link New: This issue is blocking JENKINS-26128 [ JENKINS-26128 ]

          Code changed in jenkins
          User: Jesse Glick
          Path:
          basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/EnvStep.java
          http://jenkins-ci.org/commit/workflow-plugin/df1825c211c5c6be0875c9d4c334c9f7aed3d8ba
          Log:
          JENKINS-27901 Noting.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/EnvStep.java http://jenkins-ci.org/commit/workflow-plugin/df1825c211c5c6be0875c9d4c334c9f7aed3d8ba Log: JENKINS-27901 Noting.

          Dominik Bartholdi added a comment - - edited

          this would really be great!
          Now that more and more plugins try to integrate/support with the workflow plugin, we start to discover the very strange object structures generated (just to satisfy the form binding) - this would at least allow to simplify some of it.

          Dominik Bartholdi added a comment - - edited this would really be great! Now that more and more plugins try to integrate/support with the workflow plugin, we start to discover the very strange object structures generated (just to satisfy the form binding) - this would at least allow to simplify some of it.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/EnvStep.java
          http://jenkins-ci.org/commit/workflow-basic-steps-plugin/2bffe36734ffdaba8cc85071b53c4d7d7bf7b509
          Log:
          JENKINS-27901 Noting.
          Originally-Committed-As: df1825c211c5c6be0875c9d4c334c9f7aed3d8ba

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/EnvStep.java http://jenkins-ci.org/commit/workflow-basic-steps-plugin/2bffe36734ffdaba8cc85071b53c4d7d7bf7b509 Log: JENKINS-27901 Noting. Originally-Committed-As: df1825c211c5c6be0875c9d4c334c9f7aed3d8ba
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 162495 ] New: JNJira + In-Review [ 180947 ]
          Andrew Bayer made changes -
          Labels Original: api form-data jelly stapler workflow New: api form-data jelly pipeline stapler workflow
          Andrew Bayer made changes -
          Labels Original: api form-data jelly pipeline stapler workflow New: api form-data jelly pipeline stapler

          Jesse Glick added a comment -

          Noting Stapler PR 134 which touches on related code.

          Jesse Glick added a comment - Noting Stapler PR 134 which touches on related code.
          Jesse Glick made changes -
          Remote Link New: This issue links to "Stapler PR 134 (Web Link)" [ 17922 ]

            Unassigned Unassigned
            jglick Jesse Glick
            Votes:
            9 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: