Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[FIXED JENKINS-10319] Moved trend configuration to descriptor.
  • Loading branch information
uhafner committed Apr 11, 2012
1 parent 6d7d152 commit fb9ebbdc5d97f584ebd32a77fe4924fb213b9e85
2 go.sh
@@ -5,4 +5,4 @@ mvn install || { echo "Build failed"; exit 1; }
cp -f target/*.hpi $HUDSON_HOME/plugins/

cd $HUDSON_HOME
java -jar jenkins.war
./debug.sh
@@ -5,7 +5,10 @@
import hudson.Extension;
import hudson.FilePath;
import hudson.model.AbstractProject;
import hudson.plugins.analysis.core.BuildHistory;
import hudson.plugins.analysis.core.PluginDescriptor;
import hudson.plugins.analysis.graph.DefaultGraphConfigurationView;
import hudson.plugins.analysis.graph.GraphConfiguration;
import hudson.plugins.warnings.parser.ParserRegistry;
import hudson.plugins.warnings.parser.Warning;
import hudson.util.CopyOnWriteList;
@@ -23,9 +26,12 @@
import net.sf.json.JSONObject;

import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.Ancestor;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerProxy;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

/**
* Descriptor for the class {@link WarningsPublisher}. Used as a singleton. The
@@ -34,7 +40,7 @@
* @author Ulli Hafner
*/
@Extension(ordinal = 100) // NOCHECKSTYLE
public final class WarningsDescriptor extends PluginDescriptor {
public final class WarningsDescriptor extends PluginDescriptor implements StaplerProxy {
private static final String CONSOLE_LOG_PARSERS_KEY = "consoleLogParsers";
private static final String FILE_LOCATIONS_KEY = "locations";
private static final String PARSER_NAME_ATTRIBUTE = "parserName";
@@ -82,6 +88,31 @@ public static String getProjectUrl(final String group) {
}
}

/**
* Returns the graph configuration screen.
*
* @param link
* the link to check
* @param request
* stapler request
* @param response
* stapler response
* @return the graph configuration or <code>null</code>
*/
public Object getDynamic(final String link, final StaplerRequest request, final StaplerResponse response) {
if ("configureDefaults".equals(link)) {
Ancestor ancestor = request.findAncestor(AbstractProject.class);
if (ancestor.getObject() instanceof AbstractProject) {
AbstractProject<?, ?> project = (AbstractProject<?, ?>)ancestor.getObject();
return new DefaultGraphConfigurationView(
new GraphConfiguration(WarningsProjectAction.getAllGraphs()), project, "warnings",
BuildHistory.create(project, WarningsResultAction.class),
project.getAbsoluteUrl() + "/descriptorByName/WarningsPublisher/configureDefaults/");
}
}
return null;
}

/**
* Instantiates a new {@link WarningsDescriptor}.
*/
@@ -344,4 +375,9 @@ private void message(final StringBuilder okMessage, final String message) {
okMessage.append(message);
}
}

/** {@inheritDoc} */
public Object getTarget() {
return this;
}
}
@@ -5,10 +5,13 @@
import hudson.plugins.analysis.core.BuildHistory;
import hudson.plugins.analysis.core.NullBuildHistory;
import hudson.plugins.analysis.core.AbstractProjectAction;
import hudson.plugins.analysis.graph.BuildResultGraph;
import hudson.plugins.analysis.graph.DefaultGraphConfigurationView;
import hudson.plugins.analysis.graph.GraphConfigurationView;
import hudson.plugins.warnings.parser.ParserRegistry;

import java.util.List;

import javax.annotation.CheckForNull;

import org.apache.commons.lang.StringUtils;
@@ -23,6 +26,15 @@
public class WarningsProjectAction extends AbstractProjectAction<WarningsResultAction> {
private final String parser;

/**
* Returns all the graphs.
*
* @return the graphs
*/
public static List<BuildResultGraph> getAllGraphs() {
return new WarningsProjectAction(null, null).getAvailableGraphs();
}

/**
* Creates a new instance of {@link WarningsProjectAction}.
*
@@ -49,6 +49,7 @@
</f:repeatable>
</f:entry>

<a href="descriptorByName/WarningsPublisher/helloWorld">Hello World</a>
<f:advanced>
<f:entry title="${%Warnings to include}" field="includePattern"
description="${%description.includePattern}">
@@ -59,7 +60,18 @@
<f:textbox/>
</f:entry>

<u:advanced id="warnings"/>
<u:failed/>

<f:entry title="${%Detect modules}" description="${%description.detectModules}">
<f:checkbox name="shouldDetectModules" checked="${instance.shouldDetectModules}"/>
</f:entry>

<u:health id="warnings"/>
<u:thresholds id="warnings"/>
<u:defaultEncoding id="warnings"/>
<f:entry title="${%Trend graph}">
<a href="descriptorByName/WarningsPublisher/configureDefaults">${%configure}</a>
</f:entry>

</f:advanced>
</j:jelly>
@@ -14,3 +14,4 @@ description.includePattern=Comma separated list of \
description.excludePattern=Comma separated list of \
<a href="http://download.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern.html">regular expressions</a> \
that specifies the files to exclude from the report (based on their absolute filename).
configure=You can define the default values for the trend graph in a separate view.
@@ -21,3 +21,5 @@ Warnings\ to\ include=Zu ber
Scan\ console\ log=Konsole durchsuchen
Scan\ workspace\ files=Dateien durchsuchen
Parser=Parser
Trend\ graph=Trend Graph
configure=Die Defaultwerte für die Konfiguration des Trends Graphen werden in einem eigenen Formular festgelegt.

0 comments on commit fb9ebbd

Please sign in to comment.