I see. I was able to do it with the find files step after installing that plugin. Thanks
On Wednesday, December 14, 2016 at 5:04:56 AM UTC-8, Michael Kobit wrote: > > Your problem is the new File( piece. The pipeline code runs on a > flyweight executor on the master, and the various steps can run on > allocated nodes. You might be able to do something using FilePath > <http://javadoc.jenkins-ci.org/hudson/FilePath.html>, but I think you > could use the findFiles step > <https://jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#findfiles-find-files-in-the-workspace> > which > would get you some information. You could then use the readFile step > <https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#readfile-read-file-from-workspace> > to > get the file contents into your pipeline execution. > > On Tue, Dec 13, 2016 at 4:36 PM anton kropp <[email protected] > <javascript:>> wrote: > >> I'm having some issues reading files from the local workspace. As part of >> my build a set of artifact files are created and I'd like to iterate over >> them, parse their json contents, and act on it in a pipeline step. However, >> I can't seem to get reading files from the workspace to work. >> >> My stage looks like: >> >> >> stage('Push docker containers') { >> def slurper = new JsonSlurper() >> >> def files = new File(env.WORKSPACE).listFiles() >> >> for (int i = 0; i < files.size(); i++) { >> def file = files[i] >> println(file.name) >> if (file.name.endsWith(".json")) { >> def json = slurper.parse(file) >> >> json.each { key, value -> >> // do stuff >> } >> } >> } >> } >> >> I keep getting a null pointer on files.size. I've tried to ls the >> workspace to see whats in it, but nothing shows up. Whats the recommended >> approach here? >> >> Thanks >> -Anton >> >> -- >> 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] <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/jenkinsci-users/fd65242f-f3a7-4ba3-8717-3146639d759a%40googlegroups.com >> >> <https://groups.google.com/d/msgid/jenkinsci-users/fd65242f-f3a7-4ba3-8717-3146639d759a%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c448ee42-ce07-4349-a599-b10568e23bf8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
