Skip to content

Commit

Permalink
Merge pull request #83 from jenkinsci/oleg-nenashev-JENKINS-48932/jep…
Browse files Browse the repository at this point in the history
…-200

[JENKINS-48932] - Update plugin to make it runable with PCT
  • Loading branch information
rsandell committed Jan 17, 2018
2 parents 6972d3b + fe19674 commit 986fd05
Show file tree
Hide file tree
Showing 35 changed files with 213 additions and 128 deletions.
1 change: 1 addition & 0 deletions Jenkinsfile
@@ -1,5 +1,6 @@
buildPlugin(
platforms: ['linux'],
jenkinsVersions: [null],
findbugs: [run: true, archive: true],
checkstyle: [archive: true, unstableTotalAll: 0]
)
65 changes: 37 additions & 28 deletions pom.xml
Expand Up @@ -11,15 +11,15 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.580.1</version>
<version>3.2</version>
<!--<relativePath>../pom.xml</relativePath>-->
</parent>

<properties>
<jenkins.version>2.7.3</jenkins.version>
<java.level>7</java.level>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<powermock.version>1.5.6</powermock.version>
<mockito.version>1.9.5</mockito.version>
<findbugs.version>3.0.1</findbugs.version>
<powermock.version>1.6.6</powermock.version>
<checkstyle.version>2.13</checkstyle.version>
</properties>

Expand Down Expand Up @@ -66,7 +66,7 @@
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public</url>
<url>https://repo.jenkins-ci.org/public</url>
</repository>
<repository>
<id>powermock-repo</id>
Expand All @@ -77,21 +77,26 @@
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public</url>
<url>https://repo.jenkins-ci.org/public</url>
</pluginRepository>
</pluginRepositories>

<dependencies>
<dependency>
<groupId>com.sonyericsson.hudson.plugins.gerrit</groupId>
<artifactId>gerrit-trigger</artifactId>
<version>2.15.0</version>
<version>2.27.2</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
</exclusion>
<exclusion>
<!-- Provided by the plugin -->
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -116,6 +121,11 @@
<artifactId>junit</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>apache-httpcomponents-client-4-api</artifactId>
<version>4.5.3-2.0</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
Expand All @@ -142,6 +152,13 @@
<artifactId>guava</artifactId>
<version>11.0.1</version>
</dependency>
<dependency>
<!-- Dependency bound conflict between MQ notifier and JTH -->
<!-- TODO: remove once MQ Notifier is updated -->
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>com.cloudbees.plugins</groupId>
<artifactId>build-flow-plugin</artifactId>
Expand Down Expand Up @@ -186,12 +203,6 @@
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
Expand All @@ -201,7 +212,13 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>2.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -216,6 +233,12 @@
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
Expand All @@ -233,18 +256,6 @@
<reuseForks>false</reuseForks>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
Expand Down Expand Up @@ -287,7 +298,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs.version}</version>
<configuration>
<xmlOutput>true</xmlOutput>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
Expand Down Expand Up @@ -341,7 +351,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs.version}</version>
<configuration>
<xmlOutput>true</xmlOutput>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
Expand Down
Expand Up @@ -89,7 +89,8 @@ public abstract class BfaGraphAction implements RootAction {
protected static final int DEFAULT_GRAPH_HEIGHT = 500;

/**
* Constant for "ABORTED"-cause (used to exclude such {@link FailureCause}s).
* Constant for "ABORTED"-cause (used to exclude such
* {@link com.sonyericsson.jenkins.plugins.bfa.model.FailureCause}s).
*/
protected static final String EXCLUDE_ABORTED = "ABORTED";

Expand Down
Expand Up @@ -310,8 +310,9 @@ public static PluginImpl getInstance() {
PluginImpl plugin = jenkins.getPlugin(PluginImpl.class);
if (plugin == null) {
throw new AssertionError("Not here yet.");
} else {
return plugin;
}
return plugin;
}

/**
Expand Down Expand Up @@ -503,7 +504,7 @@ public static boolean needToAnalyze(Result result) {
*
* @param build the build
* @return true if it should be scanned.
* @see {@link #shouldScan(Job)}
* @see #shouldScan(Job)
*/
public static boolean shouldScan(Run build) {
return shouldScan(build.getParent());
Expand Down
Expand Up @@ -119,7 +119,7 @@ public static int getExpirationTime() {
* Get the Graph corresponding to the specified key.
* If there is no cached graph for the specified key
* (or it has been invalidated) the specified
* Callable<Graph> will be called.
* {@code Callable<Graph>} will be called.
* @param key The key for the graph
* @param callable A callback to construct the graph that wasn't cached
* @return A cached graph, or a new graph if there was no cached instance
Expand Down
Expand Up @@ -39,7 +39,7 @@ public enum GraphType {
BAR_CHART_CAUSES_SMALL(1),

/**
* Constant for bar chart with {@link FailureCause}s.
* Constant for bar chart with {@link com.sonyericsson.jenkins.plugins.bfa.model.FailureCause}s.
*/
BAR_CHART_CAUSES(2),

Expand All @@ -54,7 +54,7 @@ public enum GraphType {
BAR_CHART_BUILD_NBRS(4),

/**
* Constant for pie chart with {@link FailureCause}s.
* Constant for pie chart with {@link com.sonyericsson.jenkins.plugins.bfa.model.FailureCause}s.
*/
PIE_CHART_CAUSES(5),

Expand All @@ -64,7 +64,7 @@ public enum GraphType {
PIE_CHART_CATEGORIES(6),

/**
* Constant for time series chart with {@link FailureCause}s.
* Constant for time series chart with {@link com.sonyericsson.jenkins.plugins.bfa.model.FailureCause}s.
*/
TIME_SERIES_CHART_CAUSES(7),

Expand Down
Expand Up @@ -166,7 +166,7 @@ public FailureCause() {

/**
* Validates this FailureCause. Checks for: {@link #doCheckName(String)}, {@link #doCheckDescription(String)},
* Indications.size > 0. and {@link com.sonyericsson.jenkins.plugins.bfa.model.indication.Indication#validate()}.
* Indications.size &gt; 0. and {@link com.sonyericsson.jenkins.plugins.bfa.model.indication.Indication#validate()}.
*
* @param newName the name to validate
* @param newDescription the description
Expand Down Expand Up @@ -659,7 +659,7 @@ public void setLastFailedBuildUrl() {

@Override
public String getDisplayName() {
return null;
return "";
}

/**
Expand Down
Expand Up @@ -300,8 +300,8 @@ private static void putToMapWithList(Map<FailureCause,
private static List<FoundFailureCause> convertToFoundFailureCauses(Map<FailureCause, List<FoundIndication>> causes) {
List<FoundFailureCause> foundFailureCauses = new ArrayList<FoundFailureCause>(causes.size());

for (FailureCause failureCause : causes.keySet()) {
foundFailureCauses.add(new FoundFailureCause(failureCause, causes.get(failureCause)));
for (Map.Entry<FailureCause, List<FoundIndication>> entry : causes.entrySet()) {
foundFailureCauses.add(new FoundFailureCause(entry.getKey(), entry.getValue()));
}

return foundFailureCauses;
Expand Down
Expand Up @@ -38,7 +38,6 @@
/**
* There is no general way to find downstream build in Jenkins Core. Different
* plugin have there own way of keeping this information.
* <p/>
* Extend this class and implement
* {@link #getDownstreamBuilds(hudson.model.Run)}
* in a way suitable for the plugin
Expand Down
Expand Up @@ -36,7 +36,6 @@

/**
* Get downstream builds for the Parameterized Trigger Plugin.
* <p/>
* We want to avoid having dependencies to other plugins thus using reflection.
*
* @author Jan-Olof Sivtoft
Expand Down
Expand Up @@ -31,6 +31,7 @@
import hudson.matrix.MatrixConfiguration;
import hudson.matrix.MatrixProject;
import hudson.model.Hudson;
import hudson.model.Item;
import hudson.model.ItemGroup;
import hudson.model.Job;
import hudson.model.Run;
Expand Down Expand Up @@ -265,21 +266,25 @@ public FormValidation doMatchText(
* We matched a folders job. Let's get the jobs up to the part were the next
* iteration can be continued from
*/
String fullFolderName = "";
StringBuilder fullFolderName = new StringBuilder();
/* The interestingJobParts string created below is meant to discard everything
* that comes before the first '/job' occurrent which is either nothing or the
* prefix from where jenkins is served, ie: http://localhost/jenkins/job/<job>/<buildNumber>
*/
String[] interestingJobParts = urlParts[0].split("/job/", 2);
String[] jobParts = interestingJobParts[interestingJobParts.length - 1].split("/job/");
for (String part: jobParts) {
fullFolderName += "/" + part;
fullFolderName.append("/").append(part);
}
getItemInstance = (ItemGroup)Jenkins.getInstance().getItemByFullName(fullFolderName);
getItemInstance = (ItemGroup)Jenkins.getInstance().getItemByFullName(fullFolderName.toString());
} else {
getItemInstance = (ItemGroup)Jenkins.getInstance();
}

if (getItemInstance == null) {
throw new AssertionError("Folder not found!");
}

/*
Find out which of the following url types testText matches, if any,
and assign to build accordingly. The url types are checked in the
Expand All @@ -289,20 +294,24 @@ public FormValidation doMatchText(
Type 3: .../<job>/<buildNumber>/<matrixInfo>/
*/

if (getItemInstance.getItem(urlParts[2]) instanceof Job
final Item itemFromPart2 = getItemInstance.getItem(urlParts[2]);
if (itemFromPart2 instanceof Job
&& isValidBuildId(urlParts[3])) {
Job project = (Job)getItemInstance.getItem(urlParts[2]);
Job project = (Job)itemFromPart2;
build = getBuildById(project, urlParts[3]);
} else if (getItemInstance.getItem(urlParts[1]) instanceof MatrixProject
&& isValidBuildId(urlParts[3])) {
MatrixProject project = (MatrixProject)getItemInstance.getItem(urlParts[1]);
MatrixConfiguration configuration = project.getItem(urlParts[2]);
build = getBuildById(configuration, urlParts[3]);
} else if (getItemInstance.getItem(urlParts[1]) instanceof MatrixProject
&& isValidBuildId(urlParts[2])) {
MatrixProject matrixProject = (MatrixProject)getItemInstance.getItem(urlParts[1]);
MatrixConfiguration configuration = matrixProject.getItem(urlParts[3]);
build = getBuildById(configuration, urlParts[2]);
} else {
final Item itemFromPart1 = getItemInstance.getItem(urlParts[1]);
if (itemFromPart1 instanceof MatrixProject
&& isValidBuildId(urlParts[3])) {
MatrixProject project = (MatrixProject)itemFromPart1;
MatrixConfiguration configuration = project.getItem(urlParts[2]);
build = getBuildById(configuration, urlParts[3]);
} else if (itemFromPart1 instanceof MatrixProject
&& isValidBuildId(urlParts[2])) {
MatrixProject matrixProject = (MatrixProject)itemFromPart1;
MatrixConfiguration configuration = matrixProject.getItem(urlParts[3]);
build = getBuildById(configuration, urlParts[2]);
}
}
if (build != null) {
try {
Expand Down

0 comments on commit 986fd05

Please sign in to comment.