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

Job DSL: strange behavior from "configure"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • job-dsl-plugin
    • 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...

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

              Created:
              Updated:
              Resolved: