On Tue, Oct 29, 2019 at 8:47 AM Tal Yanai <[email protected]> wrote:
> if(build.getWorkspace().isRemote()){
>   channel = (hudson.remoting.Channel) 
> build.getExecutor().getCurrentWorkspace().getChannel();
>   hudson.FilePath newFile = new hudson.FilePath(channel, fileOnDiskPath);
> }

No need to check `isRemote` nor to cast to `Channel` nor to call the
`FilePath` constructor manually. Just use

FilePath newFile = build.getWorkspace().child(fileOnDiskPath);

unconditionally. You would typically pass a relative pathname; see:
https://javadoc.jenkins.io/hudson/FilePath.html#child-java.lang.String-

> This works OK when "build" is AbstractBuild, but it's a puzzle to me how do I 
> get it when 'build' is from type "hudson.model.Run".

For a Pipeline build? There is no equivalent concept. A `FilePath
workspace` will be provided to you from various extension points, in
this case probably `SimpleBuildStep`:

https://jenkins.io/doc/developer/plugin-development/pipeline-integration/#basic-update

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" 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-dev/CANfRfr1Zy%3DM93RMK0nOFeERYMzzC4MTHcA3MJwUdiscDpCWw7w%40mail.gmail.com.

Reply via email to