Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add input & output directory parameters

Add help files for parameters
  • Loading branch information...
commit 14debde9d1d7fe49df6249ce371f9a142a94e9d0 1 parent 6058188
Vaclav Tunka authored
42 src/main/java/org/jenkinsci/plugins/TattletaleBuilder.java
@@ -23,7 +23,7 @@
23 23 * {@link DescriptorImpl#newInstance(StaplerRequest)} is invoked
24 24 * and a new {@link TattletaleBuilder} is created. The created
25 25 * instance is persisted to the project configuration XML by using
26   - * XStream, so this allows you to use instance fields (like {@link #projectLocation})
  26 + * XStream, so this allows you to use instance fields (like {@link #inputDirectory})
27 27 * to remember the configuration.
28 28 *
29 29 * <p>
@@ -34,32 +34,43 @@
34 34 */
35 35 public class TattletaleBuilder extends Builder {
36 36
37   - private final String projectLocation;
  37 + private final String inputDirectory;
  38 +
  39 + private final String outputDirectory;
38 40
39 41 // Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
40 42 @DataBoundConstructor
41   - public TattletaleBuilder(String projectLocation) {
42   - this.projectLocation = projectLocation;
  43 + public TattletaleBuilder(String inputDirectory, String outputDirectory) {
  44 + this.inputDirectory = inputDirectory;
  45 + this.outputDirectory = outputDirectory;
43 46 }
44 47
45 48 /**
46 49 * We'll use this from the <tt>config.jelly</tt>.
47 50 */
48   - public String getProjectLocation() {
49   - return projectLocation;
  51 + public String getInputDirectory() {
  52 + return inputDirectory;
50 53 }
51 54
52   - @Override
  55 + public String getOutputLocation() {
  56 + return outputDirectory;
  57 + }
  58 +
  59 + @Override
53 60 public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) {
54 61 // This is where you 'build' the project.
55 62
56   - listener.getLogger().println("Project "+projectLocation+"!");
  63 + listener.getLogger().println("Input directory: " + inputDirectory);
  64 +
  65 + listener.getLogger().println("Output directory: " + outputDirectory);
57 66
58 67 // This also shows how you can consult the global configuration of the builder
59 68 if (getDescriptor().getOverrideConfig()) {
60 69 listener.getLogger().println("Default global config overriden.");
61 70 listener.getLogger().println("Tattletale jar location: \n"
62 71 + getDescriptor().getTattletaleJarLocation());
  72 + listener.getLogger().println("Javassist jar location: \n"
  73 + + getDescriptor().getJavassistJarLocation());
63 74 listener.getLogger().println("Tattletale properties location: \n"
64 75 + getDescriptor().getPropertiesLocation());
65 76
@@ -96,9 +107,11 @@ public DescriptorImpl getDescriptor() {
96 107 private boolean overrideConfig;
97 108
98 109 private String tattletaleJarLocation;
  110 +
  111 + private String javassistJarLocation;
99 112
100 113 private String propertiesLocation;
101   -
  114 +
102 115 /**
103 116 * Performs on-the-fly validation of the form field 'name'.
104 117 *
@@ -133,7 +146,8 @@ public boolean configure(StaplerRequest req, JSONObject formData) throws FormExc
133 146 // To persist global configuration information,
134 147 // set that to properties and call save().
135 148 overrideConfig = formData.getBoolean("overrideConfig");
136   - tattletaleJarLocation = formData.getString("jarLocation");
  149 + tattletaleJarLocation = formData.getString("tattletaleJarLocation");
  150 + javassistJarLocation = formData.getString("javassistJarLocation");
137 151 propertiesLocation = formData.getString("propertiesLocation");
138 152 // ^Can also use req.bindJSON(this, formData);
139 153 // (easier when there are many fields; need set* methods for this, like setUseFrench)
@@ -142,8 +156,7 @@ public boolean configure(StaplerRequest req, JSONObject formData) throws FormExc
142 156 }
143 157
144 158 /**
145   - * This method returns true if the global configuration says we should speak French.
146   - *
  159 + *
147 160 * The method name is bit awkward because global.jelly calls this method to determine
148 161 * the initial state of the checkbox by the naming convention.
149 162 */
@@ -154,10 +167,15 @@ public boolean getOverrideConfig() {
154 167 public String getTattletaleJarLocation() {
155 168 return tattletaleJarLocation;
156 169 }
  170 +
  171 + public String getJavassistJarLocation() {
  172 + return javassistJarLocation;
  173 + }
157 174
158 175 public String getPropertiesLocation() {
159 176 return propertiesLocation;
160 177 }
  178 +
161 179 }
162 180 }
163 181
12 src/main/resources/org/jenkinsci/plugins/TattletaleBuilder/config.jelly
@@ -9,7 +9,15 @@
9 9 Creates a text field that shows the value of the "name" property.
10 10 When submitted, it will be passed to the corresponding constructor parameter.
11 11 -->
12   - <f:entry title="Project location" field="projectLocation">
13   - <f:textbox />
  12 + <f:entry title="Input directory"
  13 + field="inputDirectory"
  14 + help="/plugin/tattletale-plugin/help-inputDirectory.html">
  15 + <f:textbox default="." />
  16 + </f:entry>
  17 +
  18 + <f:entry title="Report output directory"
  19 + field="outputDirectory"
  20 + help="/plugin/tattletale-plugin/help-outputDirectory.html">
  21 + <f:textbox default="tattletale-report" />
14 22 </f:entry>
15 23 </j:jelly>
7 src/main/resources/org/jenkinsci/plugins/TattletaleBuilder/global.jelly
@@ -28,7 +28,12 @@
28 28 </f:entry>
29 29
30 30 <f:entry title="Tattletale jar location"
31   - field="jarLocation">
  31 + field="tattletaleJarLocation">
  32 + <f:textbox />
  33 + </f:entry>
  34 +
  35 + <f:entry title="Javassist jar location"
  36 + field="javassistJarLocation">
32 37 <f:textbox />
33 38 </f:entry>
34 39
6 src/main/resources/org/jenkinsci/plugins/TattletaleBuilder/help-name.html
... ... @@ -1,6 +0,0 @@
1   -<div>
2   - Help file for fields are discovered through a file name convention. This file is
3   - help for the "name" field. You can have <i>arbitrary</i> HTML here. You can write
4   - this file as a Jelly script if you need a dynamic content (but if you do so, change
5   - the extension to <tt>.jelly</tt>).
6   -</div>
6 src/main/resources/org/jenkinsci/plugins/TattletaleBuilder/help-useFrench.html
... ... @@ -1,6 +0,0 @@
1   -<div>
2   - This HTML fragment will be injected into the configuration screen
3   - when the user clicks the 'help' icon. See global.jelly for how the
4   - form decides which page to load.
5   - You can have any <tt>HTML</tt> fragment here.
6   -</div>
3  src/main/webapp/help-inputDirectory.html
... ... @@ -0,0 +1,3 @@
  1 +<div>
  2 + Input directory containing jars to be analyzed.
  3 +</div>
3  src/main/webapp/help-outputDirectory.html
... ... @@ -0,0 +1,3 @@
  1 +<div>
  2 + Tattletale reports will be generated into this directory.
  3 +</div>

0 comments on commit 14debde

Please sign in to comment.
Something went wrong with that request. Please try again.