[workflow plugin] list files in workspace

564 views
Skip to first unread message

Shane Kim

unread,
Feb 4, 2015, 5:28:49 PM2/4/15
to jenkins...@googlegroups.com
maybe it's simple thing but I just couldn't find or get it working. How would I get the current workspace directory path?
I've tried these:

env.WORKSPACE // gives me null
new File('.') // gives me Jenkins installation path rather than workspace
ws { new File('.') } // gives me Jenkins installation path again.


Any hints?

Thanks,
s.

James Nord

unread,
Feb 5, 2015, 3:25:01 AM2/5/15
to jenkins...@googlegroups.com, Shane Kim
It is either dir or pwd step, I don't recall which of the top of my head but one of those will return it for you.
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

John Mellor

unread,
Feb 5, 2015, 8:56:02 AM2/5/15
to jenkins...@googlegroups.com

Shell to pwd on any unix-like host will give the correct result.

--
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/157d75a7-365d-454b-8d57-2b4d4e271271%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shane Kim

unread,
Feb 5, 2015, 7:17:15 PM2/5/15
to jenkins...@googlegroups.com, shins...@gmail.com
It was pwd, but I had to call 'toString' after pwd() 'cause it returns ArrayList.

Thanks!

Jesse Glick

unread,
Feb 25, 2015, 6:08:22 PM2/25/15
to jenkins...@googlegroups.com
On Wednesday, February 4, 2015 at 5:28:49 PM UTC-5, Shane Kim wrote:
maybe it's simple thing but I just couldn't find or get it working. How would I get the current workspace directory path?

pwd() returns a String (not an ArrayList as you claim!) of the current workspace path.

env.WORKSPACE // gives me null

Yes, see related discussion about NODE_NAME.
 
new File('.') // gives me Jenkins installation path rather than workspace
ws { new File('.') } // gives me Jenkins installation path again.

It does not make sense to use java.io.File from a flow script, because the Groovy code always runs on the Jenkins master, not the slave.
Reply all
Reply to author
Forward
0 new messages