forked from vjuranek/radargun-plugin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIXED JENKINS-24545] Allow loading node list from file
- Loading branch information
Showing
7 changed files
with
143 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/org/jenkinsci/plugins/radargun/config/FileNodeSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.jenkinsci.plugins.radargun.config; | ||
|
||
import hudson.Extension; | ||
import hudson.FilePath; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import org.jenkinsci.plugins.radargun.model.NodeList; | ||
import org.jenkinsci.plugins.radargun.util.ParseUtils; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
public class FileNodeSource extends NodeSource { | ||
|
||
private final String nodeListPath; | ||
|
||
@DataBoundConstructor | ||
public FileNodeSource(String nodeListPath) { | ||
this.nodeListPath = nodeListPath; | ||
} | ||
|
||
public String getNodeListPath() { | ||
return nodeListPath; | ||
} | ||
|
||
@Override | ||
public NodeList getNodesList() throws IOException { | ||
//String path = Resolver.buildVar(build, nodeListPath); //TODO resolve build variables in path | ||
FilePath fp = new FilePath(new File(nodeListPath)); | ||
String nodes = fp.readToString(); | ||
return ParseUtils.parseNodeList(nodes); | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends NodeSourceDescriptor { | ||
public String getDisplayName() { | ||
return "Node list from file"; | ||
} | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/org/jenkinsci/plugins/radargun/config/NodeSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.jenkinsci.plugins.radargun.config; | ||
|
||
import java.io.IOException; | ||
|
||
import hudson.DescriptorExtensionList; | ||
import hudson.model.Describable; | ||
import hudson.model.Descriptor; | ||
import jenkins.model.Jenkins; | ||
|
||
import org.jenkinsci.plugins.radargun.model.NodeList; | ||
|
||
public abstract class NodeSource implements Describable<NodeSource> { | ||
|
||
public abstract NodeList getNodesList() throws IOException; | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public Descriptor<NodeSource> getDescriptor() { | ||
return Jenkins.getInstance().getDescriptorOrDie(getClass()); | ||
} | ||
|
||
public static final DescriptorExtensionList<NodeSource, Descriptor<NodeSource>> all() { | ||
return Jenkins.getInstance().getDescriptorList(NodeSource.class); | ||
} | ||
|
||
public static abstract class NodeSourceDescriptor extends Descriptor<NodeSource> { | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/org/jenkinsci/plugins/radargun/config/TextNodeSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.jenkinsci.plugins.radargun.config; | ||
|
||
import hudson.Extension; | ||
|
||
import org.jenkinsci.plugins.radargun.model.NodeList; | ||
import org.jenkinsci.plugins.radargun.util.ParseUtils; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
public class TextNodeSource extends NodeSource { | ||
|
||
private final String nodes; | ||
|
||
@DataBoundConstructor | ||
public TextNodeSource(String nodes) { | ||
this.nodes = nodes; | ||
} | ||
|
||
public String getNodes() { | ||
return nodes; | ||
} | ||
|
||
@Override | ||
public NodeList getNodesList() { | ||
return ParseUtils.parseNodeList(nodes); | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends NodeSourceDescriptor { | ||
public String getDisplayName() { | ||
return "Text node list"; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/resources/org/jenkinsci/plugins/radargun/config/FileNodeSource/config.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" | ||
xmlns:f="/lib/form"> | ||
|
||
<f:entry field="nodeListPath"> | ||
<f:textbox /> | ||
</f:entry> | ||
|
||
</j:jelly> |
8 changes: 8 additions & 0 deletions
8
src/main/resources/org/jenkinsci/plugins/radargun/config/TextNodeSource/config.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" | ||
xmlns:f="/lib/form"> | ||
|
||
<f:entry field="nodes"> | ||
<f:textarea /> | ||
</f:entry> | ||
|
||
</j:jelly> |