RE: workflow issue with "dir"
Yes - that fixed it. Thanks Daniel. > -Original Message- > From: jenkinsci-dev@googlegroups.com [mailto:jenkinsci- > d...@googlegroups.com] On Behalf Of Daniel Beck > Sent: 15 August 2014 18:33 > To: jenkinsci-dev@googlegroups.com > Subject: Re: workflow issue with "dir" > > From the error message, it seems "dir" requires a block containing the > commands to run in the specified directory. Try something like > > dir ('foobar') { >sh 'pwd' > } > > On 15.08.2014, at 19:02, James Nord (jnord) wrote: > > > Hi all, > > > > There seems to be an issue with the workflow "Change Directory" step (or > me...) > > > > With the following workflow > > node() { > > sh 'rm -fr -- *' > > sh 'mkdir foobar' > > echo 'about to change dir' > > dir 'foobar' > > echo 'changed dir' > > } > > > > I get the following output > > > > Running: Allocate node : Start > > Running on master in /opt/jenkins/data/jobs/changedir/workspace > > Running: Allocate node : Body : Start > > Running: Shell Script > > [workspace] $ nohup sh -c > "'/opt/jenkins/data/jobs/changedir/workspace/.8e7bf62b/script.sh' > > '/opt/jenkins/data/jobs/changedir/workspace/.8e7bf62b/jenkins-log.txt' > 2>&1; echo $? > > '/opt/jenkins/data/jobs/changedir/workspace/.8e7bf62b/jenkins-result.txt'" > > + rm -fr -- '*' > > Running: Shell Script > > [workspace] $ nohup sh -c > "'/opt/jenkins/data/jobs/changedir/workspace/.22ea1fbb/script.sh' > > '/opt/jenkins/data/jobs/changedir/workspace/.22ea1fbb/jenkins-log.txt' > 2>&1; echo $? > > '/opt/jenkins/data/jobs/changedir/workspace/.22ea1fbb/jenkins-result.txt'" > > + mkdir foobar > > Running: Print Message > > about to change dir > > Running: Change Directory > > Running in /opt/jenkins/data/jobs/changedir/workspace/foobar > > Running: Allocate node : Body : End > > Running: Allocate node : End > > Running: End of Workflow > > java.lang.IllegalStateException: There's no body to invoke > > at > org.jenkinsci.plugins.workflow.cps.CpsStepContext.invokeBodyLater(CpsSte > pContext.java:226) > > at > org.jenkinsci.plugins.workflow.cps.CpsStepContext.invokeBodyLater(CpsSte > pContext.java:217) > > at > org.jenkinsci.plugins.workflow.steps.PushdStep$Execution.start(PushdStep. > java:77) > > at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:131) > > at > org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:7 > 9) > > at > org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClass > Site.java:45) > > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.j > ava:42) > > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.ja > va:108) > > at > com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvo > ker.java:15) > > at Script1.run(Script1.groovy:5) > > at Unknown.Unknown(Unknown) > > at ___cps.transform___(Native Method) > > at > com.cloudbees.groovy.cps.impl.ContinuationGroup$1.call(ContinuationGrou > p.java:66) > > at > com.cloudbees.groovy.cps.impl.ContinuationGroup$1.call(ContinuationGrou > p.java:62) > > at sun.reflect.GeneratedMethodAccessor366.invoke(Unknown Source) > > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces > sorImpl.java:43) > > at java.lang.reflect.Method.invoke(Method.java:606) > > at > org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java: > 90) > > at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) > > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1079) > > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:903) > > at > org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClass > Site.java:44) > > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.ja > va:112) > > at > com.cloudbees.groovy.cps.CategorySupport$_use_closure1.doCall(Category > Support.groovy:15) > > at sun.reflect.GeneratedMethodAccessor365.invoke(Unknown Source) > > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces > sorImpl.java:43) > > at java.lang.reflect.Method.invoke(Method.java:606) > > at > org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.
Re: workflow issue with "dir"
>From the error message, it seems "dir" requires a block containing the >commands to run in the specified directory. Try something like dir ('foobar') { sh 'pwd' } On 15.08.2014, at 19:02, James Nord (jnord) wrote: > Hi all, > > There seems to be an issue with the workflow "Change Directory" step (or > me...) > > With the following workflow > node() { > sh 'rm -fr -- *' > sh 'mkdir foobar' > echo 'about to change dir' > dir 'foobar' > echo 'changed dir' > } > > I get the following output > > Running: Allocate node : Start > Running on master in /opt/jenkins/data/jobs/changedir/workspace > Running: Allocate node : Body : Start > Running: Shell Script > [workspace] $ nohup sh -c > "'/opt/jenkins/data/jobs/changedir/workspace/.8e7bf62b/script.sh' > > '/opt/jenkins/data/jobs/changedir/workspace/.8e7bf62b/jenkins-log.txt' 2>&1; > echo $? > > '/opt/jenkins/data/jobs/changedir/workspace/.8e7bf62b/jenkins-result.txt'" > + rm -fr -- '*' > Running: Shell Script > [workspace] $ nohup sh -c > "'/opt/jenkins/data/jobs/changedir/workspace/.22ea1fbb/script.sh' > > '/opt/jenkins/data/jobs/changedir/workspace/.22ea1fbb/jenkins-log.txt' 2>&1; > echo $? > > '/opt/jenkins/data/jobs/changedir/workspace/.22ea1fbb/jenkins-result.txt'" > + mkdir foobar > Running: Print Message > about to change dir > Running: Change Directory > Running in /opt/jenkins/data/jobs/changedir/workspace/foobar > Running: Allocate node : Body : End > Running: Allocate node : End > Running: End of Workflow > java.lang.IllegalStateException: There's no body to invoke > at > org.jenkinsci.plugins.workflow.cps.CpsStepContext.invokeBodyLater(CpsStepContext.java:226) > at > org.jenkinsci.plugins.workflow.cps.CpsStepContext.invokeBodyLater(CpsStepContext.java:217) > at > org.jenkinsci.plugins.workflow.steps.PushdStep$Execution.start(PushdStep.java:77) > at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:131) > at > org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:79) > at > org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) > at > com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:15) > at Script1.run(Script1.groovy:5) > at Unknown.Unknown(Unknown) > at ___cps.transform___(Native Method) > at > com.cloudbees.groovy.cps.impl.ContinuationGroup$1.call(ContinuationGroup.java:66) > at > com.cloudbees.groovy.cps.impl.ContinuationGroup$1.call(ContinuationGroup.java:62) > at sun.reflect.GeneratedMethodAccessor366.invoke(Unknown Source) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:606) > at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) > at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1079) > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:903) > at > org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:44) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112) > at > com.cloudbees.groovy.cps.CategorySupport$_use_closure1.doCall(CategorySupport.groovy:15) > at sun.reflect.GeneratedMethodAccessor365.invoke(Unknown Source) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:606) > at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) > at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) > at > org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:903) > at > org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141) > at > com.cloudbees.groovy.cps.CategorySupport$_use_closure1.doCall(CategorySupport.groovy) > at sun.reflect.GeneratedMethodAccessor364.invoke(Unknown Source) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:606) > at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) > at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) > at > org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:903) > at groovy.lang.Closure.call(Closure.java:415) > at groovy.lang.Closure.call(Closure.java:409) >