Skip to content
Permalink
Browse files

[JENKINS-29704] Adding workflow compatibility

  • Loading branch information
amuniz committed Aug 7, 2015
1 parent af9f72d commit a709ab3c53f4f38e070f2ddbdf91c6b9cb505543
26 pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-pom</artifactId>
<version>1.59</version>
<version>1.63</version>
</parent>

<artifactId>tasks</artifactId>
@@ -16,6 +16,10 @@
and generates a trend report.
</description>

<properties>
<workflow.version>1.4</workflow.version>
</properties>

<licenses>
<license>
<name>MIT license</name>
@@ -37,14 +41,32 @@
<dependency>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-core</artifactId>
<version>1.73-SNAPSHOT</version>
<version>1.73-beta-SNAPSHOT</version><!-- TODO: change to 1.73 before release -->
</dependency>
<dependency>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-test</artifactId>
<version>1.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<scm>
@@ -4,14 +4,19 @@

import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

import hudson.FilePath;
import hudson.Launcher;
import hudson.matrix.MatrixAggregator;
import hudson.matrix.MatrixBuild;

import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Run;
import hudson.model.Action;
import hudson.model.BuildListener;

import hudson.plugins.analysis.core.BuildResult;
import hudson.plugins.analysis.core.HealthAwarePublisher;
import hudson.plugins.analysis.util.PluginLogger;
@@ -30,19 +35,183 @@
/** Default files pattern. */
private static final String DEFAULT_PATTERN = "**/*.java";
/** Tag identifiers indicating high priority. */
private final String high;
private String high;
/** Tag identifiers indicating normal priority. */
private final String normal;
private String normal;
/** Tag identifiers indicating low priority. */
private final String low;
private String low;
/** Tag identifiers indicating case sensitivity. */
private final boolean ignoreCase;
private boolean ignoreCase;
/** If the identifiers should be treated as regular expression. */
private final boolean asRegexp;
private boolean asRegexp;
/** Ant file-set pattern of files to work with. */
private final String pattern;
private String pattern;
/** Ant file-set pattern of files to exclude from work. */
private final String excludePattern;
private String excludePattern;
/** Plugin name */
private static final String PLUGIN_NAME = "TASKS";

/**
* Simplified default constructor.
* Use setters to initialize if required.
*/
@DataBoundConstructor
public TasksPublisher() {
super(PLUGIN_NAME);
}

/**
* Returns the Ant file-set pattern of files to work with.
*
* @return Ant file-set pattern of files to work with
*/
public String getPattern() {
return pattern;
}

/**
* @see {@link #getPattern()}
*/
@DataBoundSetter
public void setPattern(String pattern) {
this.pattern = pattern;
}

/**
* Returns the Ant file-set pattern of files to exclude from work.
*
* @return Ant file-set pattern of files to exclude from work
*/
public String getExcludePattern() {
return excludePattern;
}

/**
* @see {@link #getExcludePattern()}
*/
@DataBoundSetter
public void setExcludePattern(String excludePattern) {
this.excludePattern = excludePattern;
}

/**
* Returns the high priority task identifiers.
*
* @return the high priority task identifiers
*/
public String getHigh() {
return high;
}

/**
* @see {@link #getHigh()}
*/
@DataBoundSetter
public void setHigh(String high) {
this.high = high;
}

/**
* Returns the normal priority task identifiers.
*
* @return the normal priority task identifiers
*/
public String getNormal() {
return normal;
}

/**
* @see {@link #getNormal()}
*/
@DataBoundSetter
public void setNormal(String normal) {
this.normal = normal;
}

/**
* Returns the low priority task identifiers.
*
* @return the low priority task identifiers
*/
public String getLow() {
return low;
}

/**
* @see {@link #getLow()}
*/
@DataBoundSetter
public void setLow(String low) {
this.low = low;
}

/**
* Returns whether case should be ignored during the scanning.
*
* @return <code>true</code> if case should be ignored during the scanning
*/
public boolean getIgnoreCase() {
return ignoreCase;
}

/**
* @see {@link #getIgnoreCase()}
*/
@DataBoundSetter
public void setIgnoreCase(boolean ignoreCase) {
this.ignoreCase = ignoreCase;
}

/**
* Returns whether the identifiers should be treated as regular expression.
*
* @return <code>true</code> if the identifiers should be treated as regular expression
*/
public boolean getAsRegexp() {
return asRegexp;
}

/**
* @see {@link #getAsRegexp()}
*/
@DataBoundSetter
public void setAsRegexp(boolean asRegexp) {
this.asRegexp = asRegexp;
}

@Override
public Action getProjectAction(final AbstractProject<?, ?> project) {
return new TasksProjectAction(project);
}

@Override
protected BuildResult perform(final Run<?, ?> build, FilePath workspace, final PluginLogger logger) throws InterruptedException, IOException {
TasksParserResult project;
WorkspaceScanner scanner = new WorkspaceScanner(StringUtils.defaultIfEmpty(getPattern(), DEFAULT_PATTERN),
getExcludePattern(), getDefaultEncoding(), high, normal, low, ignoreCase, shouldDetectModules(), asRegexp);
project = workspace.act(scanner);

logger.logLines(project.getLogMessages());
logger.log(String.format("Found %d open tasks.", project.getNumberOfAnnotations()));

TasksResult result = new TasksResult(build, getDefaultEncoding(), project,
usePreviousBuildAsReference(), useOnlyStableBuildsAsReference(), high, normal, low);
build.addAction(new TasksResultAction(build, this, result));

return result;
}

@Override
public TasksDescriptor getDescriptor() {
return (TasksDescriptor)super.getDescriptor();
}

@Override
public MatrixAggregator createAggregator(final MatrixBuild build, final Launcher launcher,
final BuildListener listener) {
return new TasksAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding(),
usePreviousBuildAsReference(), useOnlyStableBuildsAsReference());
}

/**
* Creates a new instance of <code>TasksPublisher</code>.
@@ -119,10 +288,12 @@
* Ant file-set pattern of files to scan for open tasks in
* @param excludePattern
* Ant file-set pattern of files to exclude from scan
* @deprecated This constructor is called internally only, but if you need to use it (for some strange reason), call
* {@link #TasksPublisher()} and available setters
*/
// CHECKSTYLE:OFF
@SuppressWarnings("PMD.ExcessiveParameterList")
@DataBoundConstructor
@Deprecated
public TasksPublisher(final String healthy, final String unHealthy, final String thresholdLimit,
final String defaultEncoding, final boolean useDeltaValues,
final String unstableTotalAll, final String unstableTotalHigh, final String unstableTotalNormal, final String unstableTotalLow,
@@ -138,7 +309,7 @@ public TasksPublisher(final String healthy, final String unHealthy, final String
failedTotalAll, failedTotalHigh, failedTotalNormal, failedTotalLow,
failedNewAll, failedNewHigh, failedNewNormal, failedNewLow,
canRunOnFailed, usePreviousBuildAsReference, useStableBuildAsReference,
shouldDetectModules, canComputeNew, true, "TASKS");
shouldDetectModules, canComputeNew, true, PLUGIN_NAME);
this.pattern = pattern;
this.excludePattern = excludePattern;
this.high = high;
@@ -148,101 +319,4 @@ public TasksPublisher(final String healthy, final String unHealthy, final String
this.asRegexp = asRegexp;
}
// CHECKSTYLE:ON

/**
* Returns the Ant file-set pattern of files to work with.
*
* @return Ant file-set pattern of files to work with
*/
public String getPattern() {
return pattern;
}

/**
* Returns the Ant file-set pattern of files to exclude from work.
*
* @return Ant file-set pattern of files to exclude from work
*/
public String getExcludePattern() {
return excludePattern;
}

/**
* Returns the high priority task identifiers.
*
* @return the high priority task identifiers
*/
public String getHigh() {
return high;
}

/**
* Returns the normal priority task identifiers.
*
* @return the normal priority task identifiers
*/
public String getNormal() {
return normal;
}

/**
* Returns the low priority task identifiers.
*
* @return the low priority task identifiers
*/
public String getLow() {
return low;
}

/**
* Returns whether case should be ignored during the scanning.
*
* @return <code>true</code> if case should be ignored during the scanning
*/
public boolean getIgnoreCase() {
return ignoreCase;
}

/**
* Returns whether the identifiers should be treated as regular expression.
*
* @return <code>true</code> if the identifiers should be treated as regular expression
*/
public boolean getAsRegexp() {
return asRegexp;
}

@Override
public Action getProjectAction(final AbstractProject<?, ?> project) {
return new TasksProjectAction(project);
}

@Override
protected BuildResult perform(final AbstractBuild<?, ?> build, final PluginLogger logger) throws InterruptedException, IOException {
TasksParserResult project;
WorkspaceScanner scanner = new WorkspaceScanner(StringUtils.defaultIfEmpty(getPattern(), DEFAULT_PATTERN),
getExcludePattern(), getDefaultEncoding(), high, normal, low, ignoreCase, shouldDetectModules(), asRegexp);
project = build.getWorkspace().act(scanner);

logger.logLines(project.getLogMessages());
logger.log(String.format("Found %d open tasks.", project.getNumberOfAnnotations()));

TasksResult result = new TasksResult(build, getDefaultEncoding(), project,
usePreviousBuildAsReference(), useOnlyStableBuildsAsReference(), high, normal, low);
build.addAction(new TasksResultAction(build, this, result));

return result;
}

@Override
public TasksDescriptor getDescriptor() {
return (TasksDescriptor)super.getDescriptor();
}

@Override
public MatrixAggregator createAggregator(final MatrixBuild build, final Launcher launcher,
final BuildListener listener) {
return new TasksAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding(),
usePreviousBuildAsReference(), useOnlyStableBuildsAsReference());
}
}

0 comments on commit a709ab3

Please sign in to comment.
You can’t perform that action at this time.