Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-38747

Job DSL: strange behavior from "configure"

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I am using the "configure" command to directly modify the XML since the Template Plugin is not supported directly.

      This is simple groovy code that produces (in my opinion) a false ArrayIndexOutOfBoundsException:

      job("Template Output Job") {
        String[] templates = ["Template1", "Template2"]
        for (int i = 0; i < templates.length; i++) {
          configure {
            it / "builders" << "hudson.plugins.templateproject.ProxyBuilder" {
              "projectName"(templates[i]);
            }
          }
        }
      }
      

      I can easily fix this by using a temporary variable:

      job("Template Output Job") {
        String[] templates = ["Template1", "Template2"]
        for (int i = 0; i < templates.length; i++) {
          String template = templates[i];
          configure {
            it / "builders" << "hudson.plugins.templateproject.ProxyBuilder" {
              "projectName"(template);
            }
          }
        }
      }
      

      There may be a good reason for this, but it is very strange from an end user point of view...

        Attachments

          Activity

            People

            Assignee:
            daspilker Daniel Spilker
            Reporter:
            w60001 Christopher Shannon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: