How to get workspace of jenkins pipeline job (WorkflowRun java API )

1,288 views
Skip to first unread message

Ayellet

unread,
Jan 30, 2017, 10:41:38 AM1/30/17
to Jenkins Developers
In the java API, I can access to the workspace path from the Run.java object: (Until today, all objects were instance of hudson.model.AbstractBuild)

hudson.model.AbstractBuild#getWorkspace()
hudson.model.Run#getExecutor().getCurrentWorkspace()

In Pipeline plugin I don’t have an access to the workspace, the run object is instance of org.jenkinsci.plugins.workflow.job.WorkflowRun and this object doesn’t link to any workspace.

also, this call return null: hudson.model.Run#getExecutor().getCurrentWorkspace()

how can I get it?



(in other words: I need an access from my plugin (java plugin), during hudson.model.listeners.RunListener flow. 
 I'm working with the back-end objects: WorkflowRun.java and FlowNode.java. and need an access point from those classes)

Daniel Beck

unread,
Jan 30, 2017, 11:16:21 AM1/30/17
to jenkin...@googlegroups.com

> On 30.01.2017, at 16:41, Ayellet <laye...@gmail.com> wrote:
>
> (in other words: I need an access from my plugin (java plugin), during hudson.model.listeners.RunListener flow.

A Pipeline run/build can have any number of different workspaces on different nodes in parallel, so the notion of "the workspace" makes no sense in that context. Your plugin will need to be redesigned (e.g. as Pipeline step) if you need access to "the" workspace for Pipeline builds.

Reply all
Reply to author
Forward
0 new messages