Re: Read files from workspace in multibranch pipeline scm?

2016-12-15 Thread anton kropp
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 
> , but I think you 
> could use the findFiles step 
> 
>  which 
> would get you some information. You could then use the readFile step 
> 
>  to 
> get the file contents into your pipeline execution.
>
> On Tue, Dec 13, 2016 at 4:36 PM anton kropp  > 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 jenkinsci-use...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/fd65242f-f3a7-4ba3-8717-3146639d759a%40googlegroups.com
>>  
>> 
>> .
>> 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 jenkinsci-users+unsubscr...@googlegroups.com.
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.


Re: Read files from workspace in multibranch pipeline scm?

2016-12-14 Thread Michael Kobit
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
, but I think you could
use the findFiles step

which
would get you some information. You could then use the readFile step

to
get the file contents into your pipeline execution.

On Tue, Dec 13, 2016 at 4:36 PM anton kropp  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 jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/fd65242f-f3a7-4ba3-8717-3146639d759a%40googlegroups.com
> 
> .
> 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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CALELY9Gr0nrmt69eS8KXAu0r4tHYqJA4GGk9ZnLv7XTMn%3DF_4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Read files from workspace in multibranch pipeline scm?

2016-12-13 Thread anton kropp
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/fd65242f-f3a7-4ba3-8717-3146639d759a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.