Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ work

# macOS
.DS_Store

.classpath
.settings
.project
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import hudson.Extension;
import hudson.model.Action;
import hudson.model.Api;
import hudson.model.Item;
import hudson.security.AccessControlled;
import java.io.IOException;
Expand All @@ -35,18 +36,20 @@
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import jenkins.model.Jenkins;
import jenkins.model.TransientActionFactory;
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graphanalysis.DepthFirstScanner;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;

/**
* Display of all {@link WorkspaceActionImpl}s for a build.
*/
@Restricted(NoExternalUse.class)
@ExportedBean
public final class WorkspaceRunAction implements Action {

private static final Logger LOGGER = Logger.getLogger(WorkspaceRunAction.class.getName());
Expand Down Expand Up @@ -93,6 +96,43 @@ public List<WorkspaceActionImpl> getActions() {
return r;
}

@Exported
public List<WorkspaceData> getWorkspaceDatas() throws IOException {
List<WorkspaceData> list = new ArrayList<>();
for (WorkspaceActionImpl action : getActions()) {
list.add(new WorkspaceData(action));
}
return list;
}

@ExportedBean(defaultVisibility = 2)
public static final class WorkspaceData {
private final String node;
private final String path;
private final String url;

WorkspaceData(WorkspaceActionImpl action) throws IOException {
node = action.getNode();
path = action.getPath();
url = Jenkins.get().getRootUrl() + action.getParent().getUrl() + action.getUrlName();
}

@Exported
public String getNode() {
return node;
}

@Exported
public String getUrl() {
return url;
}

@Exported
public String getPath() {
return path;
}
}

@Extension public static final class Factory extends TransientActionFactory<FlowExecutionOwner.Executable> {

@Override public Class<FlowExecutionOwner.Executable> type() {
Expand All @@ -109,4 +149,7 @@ public List<WorkspaceActionImpl> getActions() {

}

public Api getApi() {
return new Api(this);
}
}