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

job-dsl-plugin unknown protocol when use in dir with mixed separator

    Details

    • Similar Issues:

      Description

      If use separator '/' in dir, then jobDsl will throw java.net.MalformedURLException: unknown protocol

      When change it to '
      ', it's ok.

              stage('Deploy') {
                  steps {
                      echo 'Add deploy scheduling job...'
                      //THERE
                      dir("${params.DeployPath}/${env.ArchiveName}") {
                          jobDsl(
                              targets: "${params.ProjectName}/jenkins/job_dsl.groovy", 
                              removedJobAction: 'DELETE', 
                              removedViewAction: 'DELETE',
                              additionalParameters: [
                                  ProjectPath: "${params.DeployPath}/${env.ArchiveName}/${params.ProjectName}"
                              ]
                          )
                      }
                  }
              }
      

       

       

       this is the error log,

       ...
       [Pipeline] stage
       [Pipeline] { (Deploy)
       [Pipeline] dir
       Running in D:\Program\ETL/[Deploy]DataCenter_20180929_100210_0fe69c1
       [Pipeline] { 
       [Pipeline] echo
       Add deploy scheduling job... 
       [Pipeline] jobDsl 
       [Pipeline] }
       [Pipeline] // dir
       [Pipeline] }
       [Pipeline] // stage
       [Pipeline] }
       [Pipeline] // node
       [Pipeline] End of Pipeline
       java.net.MalformedURLException: unknown protocol: d
       at java.net.URL.<init>(Unknown Source)
       at java.net.URL.<init>(Unknown Source)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
       at java.lang.reflect.Constructor.newInstance(Unknown Source)
       at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
       at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77)
       at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
       at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:255)
       at javaposse.jobdsl.plugin.ScriptRequestGenerator.createWorkspaceUrl(ScriptRequestGenerator.groovy:93)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
       at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
       at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
       at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
       at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
       at javaposse.jobdsl.plugin.ScriptRequestGenerator$_getScriptRequests_closure2.doCall(ScriptRequestGenerator.groovy:50)
       at sun.reflect.GeneratedMethodAccessor1908.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
       at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
       at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
       at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
       at groovy.lang.Closure.call(Closure.java:414)
       at groovy.lang.Closure.call(Closure.java:430)
       at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2040)
       at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1895)
       at org.codehaus.groovy.runtime.dgm$159.invoke(Unknown Source)
       at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
       at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
       at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
       at javaposse.jobdsl.plugin.ScriptRequestGenerator.getScriptRequests(ScriptRequestGenerator.groovy:42)
       at javaposse.jobdsl.plugin.ExecuteDslScripts.perform(ExecuteDslScripts.java:326)
       at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80)
       at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67)
       at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1$1.call(SynchronousNonBlockingStepExecution.java:50)
       at hudson.security.ACL.impersonate(ACL.java:290)
       at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1.run(SynchronousNonBlockingStepExecution.java:47)
       at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
       at java.util.concurrent.FutureTask.run(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)
       Finished: FAILURE
      
      

       

        Attachments

          Activity

          Hide
          daspilker Daniel Spilker added a comment -

          I can not reproduce the problem.

          This pipeline script works for me:

          node {
              writeFile file: 'foo/bar/test.groovy', text: 'job("example")'
              jobDsl targets: 'foo\\bar/test.groovy'
          }
          
          Started by user admin
          Running as admin
          Running in Durability level: MAX_SURVIVABILITY
          [Pipeline] Start of Pipeline
          [Pipeline] node
          Running on Jenkins in /var/jenkins_home/workspace/example-pipe
          [Pipeline] {
          [Pipeline] writeFile
          [Pipeline] jobDsl
          Processing DSL script foo/bar/test.groovy
          Added items:
              GeneratedJob{name='example'}
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          Finished: SUCCESS
          
          Show
          daspilker Daniel Spilker added a comment - I can not reproduce the problem. This pipeline script works for me: node { writeFile file: 'foo/bar/test.groovy' , text: 'job( "example" )' jobDsl targets: 'foo\\bar/test.groovy' } Started by user admin Running as admin Running in Durability level: MAX_SURVIVABILITY [Pipeline] Start of Pipeline [Pipeline] node Running on Jenkins in / var /jenkins_home/workspace/example-pipe [Pipeline] { [Pipeline] writeFile [Pipeline] jobDsl Processing DSL script foo/bar/test.groovy Added items: GeneratedJob{name= 'example' } [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS
          Hide
          xiaoyao9184 XiaoYao LingHu added a comment - - edited

          Daniel Spilker Only wrong in windows system and also use step ‘dir’

          node {
              //not use step 'dir'
              writeFile file: 'foo/bar/test.groovy', text: 'job("example")'
              jobDsl targets: 'foo\\bar/test.groovy'
          
              //use step 'dir' no mixed separator
              dir("D:\\") {
                  writeFile file: 'foo/bar/test.groovy', text: 'job("example")'
                  jobDsl targets: 'foo\\bar/test.groovy'
              }
          
              //use step 'dir' with mixed separator
              dir("D:\\foo/bar") {
                  writeFile file: 'test.groovy', text: 'job("example")'
                  jobDsl targets: 'test.groovy'
              }
              
          }
          Running in Durability level: MAX_SURVIVABILITY
          [Pipeline] node
          Running on Jenkins in D:\Program\Jenkins\workspace\test
          [Pipeline] {
          [Pipeline] writeFile
          [Pipeline] jobDsl
          Processing DSL script test.groovy
          Existing items:
              GeneratedJob{name='example'}
          [Pipeline] dir
          Running in D:\
          [Pipeline] {
          [Pipeline] writeFile
          [Pipeline] jobDsl
          Processing DSL script test.groovy
          Existing items:
              GeneratedJob{name='example'}
          [Pipeline] }
          [Pipeline] // dir
          [Pipeline] dir
          Running in D:\foo/bar
          [Pipeline] {
          [Pipeline] writeFile
          [Pipeline] jobDsl
          [Pipeline] }
          [Pipeline] // dir
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          java.net.MalformedURLException: unknown protocol: d
          	at java.net.URL.<init>(Unknown Source)
          	at java.net.URL.<init>(Unknown Source)
          
          Show
          xiaoyao9184 XiaoYao LingHu added a comment - - edited Daniel Spilker  Only wrong in windows system and also use step ‘dir’ node { //not use step 'dir' writeFile file: 'foo/bar/test.groovy' , text: 'job( "example" )' jobDsl targets: 'foo\\bar/test.groovy' //use step 'dir' no mixed separator dir( "D:\\" ) { writeFile file: 'foo/bar/test.groovy' , text: 'job( "example" )' jobDsl targets: 'foo\\bar/test.groovy' } //use step 'dir' with mixed separator dir( "D:\\foo/bar" ) { writeFile file: 'test.groovy' , text: 'job( "example" )' jobDsl targets: 'test.groovy' } } Running in Durability level: MAX_SURVIVABILITY [Pipeline] node Running on Jenkins in D:\Program\Jenkins\workspace\test [Pipeline] { [Pipeline] writeFile [Pipeline] jobDsl Processing DSL script test.groovy Existing items: GeneratedJob{name= 'example' } [Pipeline] dir Running in D:\ [Pipeline] { [Pipeline] writeFile [Pipeline] jobDsl Processing DSL script test.groovy Existing items: GeneratedJob{name= 'example' } [Pipeline] } [Pipeline] // dir [Pipeline] dir Running in D:\foo/bar [Pipeline] { [Pipeline] writeFile [Pipeline] jobDsl [Pipeline] } [Pipeline] // dir [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline java.net.MalformedURLException: unknown protocol: d at java.net.URL.<init>(Unknown Source) at java.net.URL.<init>(Unknown Source)
          Hide
          xiaoyao9184 XiaoYao LingHu added a comment -

          Additional comments

          Show
          xiaoyao9184 XiaoYao LingHu added a comment - Additional comments
          Show
          daspilker Daniel Spilker added a comment - See https://groups.google.com/d/topic/job-dsl-plugin/IFj5SIIRwyc/discussion

            People

            • Assignee:
              daspilker Daniel Spilker
              Reporter:
              xiaoyao9184 XiaoYao LingHu
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: