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

Make Job DSL's ExecuteDslScripts Pipeline-compatible

    Details

    • Similar Issues:

      Attachments

        Issue Links

          Activity

          Hide
          daspilker Daniel Spilker added a comment -
          Show
          daspilker Daniel Spilker added a comment - https://github.com/jenkinsci/job-dsl-plugin/pull/862 Will be released in 1.48.
          Show
          daspilker Daniel Spilker added a comment - The documentation for this is in the wiki: https://github.com/jenkinsci/job-dsl-plugin/wiki/User-Power-Moves#use-job-dsl-in-pipeline-scripts
          Hide
          misery A. Klitzing added a comment -

          I get this stacktrace....

          Jenkins 2.11 (plugins updated)
          Job-DSL 1.48

          Jenkinsfile

          node {
          	step([
          		$class: 'ExecuteDslScripts',
          		scriptLocation: [targets: ['resources/jenkins/dsl/*.groovy', 'resources/jenkins/dsl/Releases/*.groovy'].join('\n')],
          		removedJobAction: 'DISABLE',
          		removedViewAction: 'DELETE',
          		lookupStrategy: 'JENKINS_ROOT',
          		additionalClasspath: 'resources/jenkins/dsl'
          	])
          }
          

          Looks like there is a workspace@script only!

          $ ls -l /var/lib/jenkins/jobs/_Seeder_
          insgesamt 16
          drwxr-xr-x  8 jenkins jenkins 4096 30. Jun 15:56 builds
          -rw-r--r--  1 jenkins jenkins  717 27. Jun 10:24 config.xml
          lrwxrwxrwx  1 jenkins jenkins   22 30. Jun 15:56 lastStable -> builds/lastStableBuild
          lrwxrwxrwx  1 jenkins jenkins   26 30. Jun 15:56 lastSuccessful -> builds/lastSuccessfulBuild
          -rw-r--r--  1 jenkins jenkins    2 30. Jun 15:56 nextBuildNumber
          drwxr-xr-x 11 jenkins jenkins 4096 30. Jun 15:56 workspace@script
          
          [workspace@script] $ hg log --rev . --template {rev}
          [Pipeline] node
          Running on master in /var/lib/jenkins/jobs/_Seeder_/workspace
          [Pipeline] {
          [Pipeline] step
          
          /var/lib/jenkins/jobs/_Seeder_/workspace does not exist.
          	at org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner(AbstractFileSet.java:483)
          	at hudson.FilePath.glob(FilePath.java:1769)
          	at hudson.FilePath.access$1700(FilePath.java:195)
          	at hudson.FilePath$32.invoke(FilePath.java:1747)
          	at hudson.FilePath$32.invoke(FilePath.java:1744)
          	at hudson.FilePath.act(FilePath.java:1018)
          	at hudson.FilePath.act(FilePath.java:996)
          	at hudson.FilePath.list(FilePath.java:1744)
          	at hudson.FilePath.list(FilePath.java:1729)
          	at hudson.FilePath.list(FilePath.java:1715)
          	at hudson.FilePath$list$2.call(Unknown Source)
          	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
          	at javaposse.jobdsl.plugin.ScriptRequestGenerator$_getScriptRequests_closure2.doCall(ScriptRequestGenerator.groovy:48)
          	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:498)
          	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:1024)
          	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:2030)
          	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1890)
          	at org.codehaus.groovy.runtime.DefaultGroovyMethods$each.call(Unknown Source)
          	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
          	at org.codehaus.groovy.runtime.DefaultGroovyMethods$each.call(Unknown Source)
          	at com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods.groovy:26)
          	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:498)
          	at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:54)
          	at org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:56)
          	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.CallSiteArray.defaultCall(CallSiteArray.java:48)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
          	at javaposse.jobdsl.plugin.ScriptRequestGenerator.getScriptRequests(ScriptRequestGenerator.groovy:47)
          	at javaposse.jobdsl.plugin.ExecuteDslScripts.perform(ExecuteDslScripts.java:275)
          	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:68)
          	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:59)
          	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:52)
          	at hudson.security.ACL.impersonate(ACL.java:213)
          	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:49)
          	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
          	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          	at java.lang.Thread.run(Thread.java:745)
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: /var/lib/jenkins/jobs/_Seeder_/workspace does not exist.
          Finished: FAILURE
          
          Show
          misery A. Klitzing added a comment - I get this stacktrace.... Jenkins 2.11 (plugins updated) Job-DSL 1.48 Jenkinsfile node { step([ $class: 'ExecuteDslScripts' , scriptLocation: [targets: [ 'resources/jenkins/dsl/*.groovy' , 'resources/jenkins/dsl/Releases/*.groovy' ].join( '\n' )], removedJobAction: 'DISABLE' , removedViewAction: 'DELETE' , lookupStrategy: 'JENKINS_ROOT' , additionalClasspath: 'resources/jenkins/dsl' ]) } Looks like there is a workspace@script only! $ ls -l / var /lib/jenkins/jobs/_Seeder_ insgesamt 16 drwxr-xr-x 8 jenkins jenkins 4096 30. Jun 15:56 builds -rw-r--r-- 1 jenkins jenkins 717 27. Jun 10:24 config.xml lrwxrwxrwx 1 jenkins jenkins 22 30. Jun 15:56 lastStable -> builds/lastStableBuild lrwxrwxrwx 1 jenkins jenkins 26 30. Jun 15:56 lastSuccessful -> builds/lastSuccessfulBuild -rw-r--r-- 1 jenkins jenkins 2 30. Jun 15:56 nextBuildNumber drwxr-xr-x 11 jenkins jenkins 4096 30. Jun 15:56 workspace@script [workspace@script] $ hg log --rev . --template {rev} [Pipeline] node Running on master in / var /lib/jenkins/jobs/_Seeder_/workspace [Pipeline] { [Pipeline] step / var /lib/jenkins/jobs/_Seeder_/workspace does not exist. at org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner(AbstractFileSet.java:483) at hudson.FilePath.glob(FilePath.java:1769) at hudson.FilePath.access$1700(FilePath.java:195) at hudson.FilePath$32.invoke(FilePath.java:1747) at hudson.FilePath$32.invoke(FilePath.java:1744) at hudson.FilePath.act(FilePath.java:1018) at hudson.FilePath.act(FilePath.java:996) at hudson.FilePath.list(FilePath.java:1744) at hudson.FilePath.list(FilePath.java:1729) at hudson.FilePath.list(FilePath.java:1715) at hudson.FilePath$list$2.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at javaposse.jobdsl.plugin.ScriptRequestGenerator$_getScriptRequests_closure2.doCall(ScriptRequestGenerator.groovy:48) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) 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:1024) 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:2030) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1890) at org.codehaus.groovy.runtime.DefaultGroovyMethods$each.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.DefaultGroovyMethods$each.call(Unknown Source) at com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods.groovy:26) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:54) at org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:56) 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.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at javaposse.jobdsl.plugin.ScriptRequestGenerator.getScriptRequests(ScriptRequestGenerator.groovy:47) at javaposse.jobdsl.plugin.ExecuteDslScripts.perform(ExecuteDslScripts.java:275) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:68) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:59) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:52) at hudson.security.ACL.impersonate(ACL.java:213) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:49) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang. Thread .run( Thread .java:745) [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: / var /lib/jenkins/jobs/_Seeder_/workspace does not exist. Finished: FAILURE
          Hide
          bitwiseman Liam Newman added a comment -

          A. Klitzing
          Perhaps open a bug?

          Show
          bitwiseman Liam Newman added a comment - A. Klitzing Perhaps open a bug?
          Hide
          cdenneen Chris Denneen added a comment - - edited

          This seems to be still happening: job-dsl 1.58

          • Create test pipeline job named 'test' pointed to repo to read Jenkinsfile

          Repo with the following Jenkinsfile

          node {
            jobDsl scriptText: 'job("example-2")'
            jobDsl scriptText: """
              def project = 'Netflix/asgard'
              def branchApi = new URL(\"https://api.github.com/repos/\${project}/branches\")
              def branches = new groovy.json.JsonSlurper().parse(branchApi.newReader())
              branches.each {
                def branchName = it.name
                def jobName = \"\${project}-\${branchName}\".replaceAll('/','-')
                job(jobName) {
                  scm {
                    git(\"https://github.com/\${project}.git\", branchName)
                  }
                }
              }
            """
            jobDsl scriptText: """
              folder('shared') {
                displayName('Shared Jobs')
                description('Shared Jobs Folder')
              }
            """
            jobDsl targets: ['jobs/*.groovy'].join('\n'),
              removedJobAction: 'DELETE',
              removedViewAction: 'DELETE',
              lookupStrategy: 'SEED_JOB'
          }
          

          Repo has a jobs subfolder with any groovy scripts...

          workspace for test is empty
          workspace of test@script has the checked out repo

          jenkins@50eeb9a40763:~/workspace$ ls -la *
          test:
          total 8
          drwxr-xr-x 2 jenkins jenkins 4096 Mar  1 18:03 .
          drwxr-xr-x 4 jenkins jenkins 4096 Mar  1 18:03 ..
          
          test@script:
          total 20
          drwxr-xr-x 4 jenkins jenkins 4096 Mar  1 18:19 .
          drwxr-xr-x 4 jenkins jenkins 4096 Mar  1 18:03 ..
          drwxr-xr-x 8 jenkins jenkins 4096 Mar  1 18:19 .git
          -rw-r--r-- 1 jenkins jenkins  835 Mar  1 18:19 Jenkinsfile
          drwxr-xr-x 2 jenkins jenkins 4096 Mar  1 18:03 jobs
          

          test job runs and fails at last step:

          ERROR: no Job DSL script(s) found at jobs/*.groovy
          
          Show
          cdenneen Chris Denneen added a comment - - edited This seems to be still happening: job-dsl 1.58 Create test pipeline job named 'test' pointed to repo to read Jenkinsfile Repo with the following Jenkinsfile node { jobDsl scriptText: 'job( "example-2" )' jobDsl scriptText: """ def project = 'Netflix/asgard' def branchApi = new URL(\ "https: //api.github.com/repos/\${project}/branches\" ) def branches = new groovy.json.JsonSlurper().parse(branchApi.newReader()) branches.each { def branchName = it.name def jobName = \ "\${project}-\${branchName}\" .replaceAll( '/' , '-' ) job(jobName) { scm { git(\ "https: //github.com/\${project}.git\" , branchName) } } } """ jobDsl scriptText: """ folder( 'shared' ) { displayName( 'Shared Jobs' ) description( 'Shared Jobs Folder' ) } """ jobDsl targets: [ 'jobs/*.groovy' ].join( '\n' ), removedJobAction: 'DELETE' , removedViewAction: 'DELETE' , lookupStrategy: 'SEED_JOB' } Repo has a jobs subfolder with any groovy scripts... workspace for test is empty workspace of test@script has the checked out repo jenkins@50eeb9a40763:~/workspace$ ls -la * test: total 8 drwxr-xr-x 2 jenkins jenkins 4096 Mar 1 18:03 . drwxr-xr-x 4 jenkins jenkins 4096 Mar 1 18:03 .. test@script: total 20 drwxr-xr-x 4 jenkins jenkins 4096 Mar 1 18:19 . drwxr-xr-x 4 jenkins jenkins 4096 Mar 1 18:03 .. drwxr-xr-x 8 jenkins jenkins 4096 Mar 1 18:19 .git -rw-r--r-- 1 jenkins jenkins 835 Mar 1 18:19 Jenkinsfile drwxr-xr-x 2 jenkins jenkins 4096 Mar 1 18:03 jobs test job runs and fails at last step: ERROR: no Job DSL script(s) found at jobs/*.groovy
          Show
          cdenneen Chris Denneen added a comment - http://stackoverflow.com/questions/37353963/how-can-i-reference-the-jenkinsfile-directory-with-pipeline
          Hide
          daspilker Daniel Spilker added a comment -

          File a bug report if something is not working as expected.

          Show
          daspilker Daniel Spilker added a comment - File a bug report if something is not working as expected.

            People

            • Assignee:
              daspilker Daniel Spilker
              Reporter:
              abayer Andrew Bayer
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: