I can write to a file successfully by adding the Jenkins workspace to the 
path. try something like this:

workspace = build.environment.get("WORKSPACE");
new File("${workspace}/foo.ini").withWriter { out ->
        out.writeLine("this is a test")
}


On Tuesday, March 4, 2014 3:59:29 AM UTC-8, dev123 wrote:
>
> I have a build flow job where the first step I need to execute is writing 
> a file to disk:
>
>
> Properties props = new Properties();
> props.setProperty("Var1", "asdasd");
> File f = new File("Configs.properties");
> OutputStream out = new FileOutputStream( f );
> props.store(out,null);
>
> When I run the job I get:
>
> Building in workspace /var/lib/jenkins/workspace/test-flow
> ERROR: Failed to run DSL Scriptjava.io.FileNotFoundException 
> <http://stacktrace.jenkins-ci.org/search?query=java.io.FileNotFoundException>:
>  Configs.properties (Permission denied)
>       at java.io.FileOutputStream.open(Native Method)
>       at java.io.FileOutputStream.<init>(FileOutputStream.java:209)
>       at java.io.FileOutputStream.<init>(FileOutputStream.java:160)
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>       at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
>       at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>       at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
>       at 
> org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
>       at 
> org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
>       at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:54)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
>       at Script1.run(Script1.groovy:4)
>       at Script1$run.call(Unknown Source)
>       at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
>       at 
> com.cloudbees.plugins.flow.FlowDSL.executeFlowScript(FlowDSL.groovy:82)
>       at com.cloudbees.plugins.flow.FlowRun$RunnerImpl.doRun(FlowRun.java:154)
>       at 
> hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:566)
>       at hudson.model.Run.execute(Run.java:1678)
>       at hudson.model.Run.run(Run.java:1625)
>       at com.cloudbees.plugins.flow.FlowRun.run(FlowRun.java:133)
>       at hudson.model.ResourceController.execute(ResourceController.java:88)
>       at hudson.model.Executor.run(Executor.java:231)
>       at hudson.model.OneOffExecutor.run(OneOffExecutor.java:43)
> FATAL: Configs.properties (Permission denied)java.io.FileNotFoundException 
> <http://stacktrace.jenkins-ci.org/search?query=java.io.FileNotFoundException>:
>  Configs.properties (Permission denied)
>
>
> Why does jenkins not have rights to write a file to the workspace where its 
> executing the job?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to