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

Job DSL Unit test fails if there are spaces in the job name

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None

      When running Job DSL unit tests based on https://github.com/jenkinsci/job-dsl-plugin/wiki/Testing-DSL-Scripts, if we create jobs that contain spaces in the job name the test fails because it can't write config.xml.  This seems to be because the path is being URL encoded (spaces replaced with %20).  If the DSL script replaces the spaces with underscores then the tests pass.

      Expected no exception to be thrown, but got 'javaposse.jobdsl.dsl.DslException'
      Expected no exception to be thrown, but got 'javaposse.jobdsl.dsl.DslException'
      at spock.lang.Specification.noExceptionThrown(Specification.java:118)
      at JobScriptsSpec.test script #file.name(JobScriptStep.groovy:25)
      Caused by: javaposse.jobdsl.dsl.DslException: java.io.IOException: Failed to persist config.xml
      at javaposse.jobdsl.plugin.JenkinsJobManagement.createNewItem(JenkinsJobManagement.java:569)
      at javaposse.jobdsl.plugin.JenkinsJobManagement.createOrUpdateConfig(JenkinsJobManagement.java:144)
      at javaposse.jobdsl.dsl.AbstractDslScriptLoader.extractGeneratedJobs_closure4(AbstractDslScriptLoader.groovy:189)
      at groovy.lang.Closure.call(Closure.java:414)
      at groovy.lang.Closure.call(Closure.java:430)
      at javaposse.jobdsl.dsl.AbstractDslScriptLoader.extractGeneratedJobs(AbstractDslScriptLoader.groovy:182)
      at javaposse.jobdsl.dsl.AbstractDslScriptLoader.extractGeneratedItems(AbstractDslScriptLoader.groovy:169)
      at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScripts_closure1(AbstractDslScriptLoader.groovy:62)
      at groovy.lang.Closure.call(Closure.java:414)
      at groovy.lang.Closure.call(Closure.java:430)
      at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScripts(AbstractDslScriptLoader.groovy:46)
      at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScript(AbstractDslScriptLoader.groovy:81)
      at JobScriptsSpec.test script #file.name(JobScriptStep.groovy:22)
      Caused by: java.io.IOException: Failed to persist config.xml
      at hudson.model.ItemGroupMixIn.createProjectFromXML(ItemGroupMixIn.java:292)
      at jenkins.model.Jenkins.createProjectFromXML(Jenkins.java:3838)
      at javaposse.jobdsl.plugin.JenkinsJobManagement.createNewItem(JenkinsJobManagement.java:561)
      ... 12 more
      Caused by: javax.xml.transform.TransformerException: java.io.FileNotFoundException: /tmp/hudson8060308975604458205test/jobs/some-job-name%20-%20R2/config.xml (No such file or directory)
      at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler(TransformerIdentityImpl.java:297)
      at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:330)
      at jenkins.util.xml.XMLUtils._transform(XMLUtils.java:212)
      at jenkins.util.xml.XMLUtils.safeTransform(XMLUtils.java:84)
      at hudson.model.ItemGroupMixIn.createProjectFromXML(ItemGroupMixIn.java:272)
      ... 14 more
      Caused by: java.io.FileNotFoundException: /tmp/hudson8060308975604458205test/jobs/some-job-name%20-%20R2/config.xml (No such file or directory)
      at java.io.FileOutputStream.open(FileOutputStream.java:270)
      at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
      at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
      at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler(TransformerIdentityImpl.java:287)
      ... 18 more

            daspilker Daniel Spilker
            gkrupa Gerard Krupa
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: