Job DSL: strange behavior from "configure"

XMLWordPrintable

    • Type: Bug
    • Resolution: Not A Defect
    • Priority: Minor
    • Component/s: job-dsl-plugin
    • Environment:
      Job DSL Plugin 1.48
      Jenkins 2.7.4

      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...

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

              Created:
              Updated:
              Resolved: