Skip to content

Commit

Permalink
Merge pull request #4 from jenkinsci/plugin-pom
Browse files Browse the repository at this point in the history
[JENKINS-37473] Plugin pom
  • Loading branch information
escoem committed Aug 17, 2016
2 parents dd3a32e + b4a2abe commit 722a8af
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 15 deletions.
5 changes: 5 additions & 0 deletions findbugs-exclude.xml
@@ -0,0 +1,5 @@
<FindBugsFilter>
<Match>
<Class name="~.+\.Messages" />
</Match>
</FindBugsFilter>
24 changes: 22 additions & 2 deletions pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.580.3</version>
<version>2.13</version>
</parent>

<artifactId>changelog-history</artifactId>
Expand All @@ -13,6 +13,13 @@
<version>1.6-SNAPSHOT</version>
<url>http://wiki.jenkins-ci.org/display/JENKINS/Change+Log+History+Plugin</url>

<properties>
<jenkins.version>1.580.3</jenkins.version>
<hpi-plugin.version>1.106</hpi-plugin.version>
<stapler-plugin.version>1.17</stapler-plugin.version>
<java.level>6</java.level>
</properties>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -21,6 +28,19 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</build>


<developers>
<developer>
<id>mindless</id>
Expand All @@ -37,7 +57,7 @@
<developerConnection>scm:git:git@github.com:jenkinsci/changelog-history-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/changelog-history-plugin</url>
<tag>HEAD</tag>
</scm>
</scm>

<repositories>
<repository>
Expand Down
Expand Up @@ -23,6 +23,7 @@
*/
package hudson.plugins.changelog_history;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.model.AbstractBuild;
import hudson.model.Action;
import hudson.scm.ChangeLogParser;
Expand Down Expand Up @@ -58,6 +59,7 @@ public ChangeLogHistoryAction(AbstractBuild<?,?> build) {
/**
* Get all changelog detail; used by index.jelly
*/
@SuppressFBWarnings(value = "REC_CATCH_EXCEPTION", justification = "legacy code")
public Map<Long,ChangeLogSet> getChangeLogSets() throws Exception {
ChangeLogParser parser = build.getProject().getScm().createChangeLogParser();
File baseDir = new File(build.getRootDir(), "changelog-history");
Expand All @@ -68,9 +70,11 @@ public boolean accept(File pathname) {
return pathname.isFile() && pathname.getName().matches("\\d+\\.xml");
}
});

if (files == null) {
throw new IllegalStateException("Null files not allowed here.");
}
// Descending sort by build number
Arrays.sort(files, new Comparator<File>() {
Arrays.sort(files , new Comparator<File>() {
public int compare(File f1, File f2) {
return Long.signum(getBuildNumber(f2) - getBuildNumber(f1));
}
Expand All @@ -81,11 +85,15 @@ public int compare(File f1, File f2) {
for (File file : files) {
ChangeLogSet changeLogSet = parser.parse(build, build.getProject().getScm().getEffectiveBrowser(), file);
// Hack to avoid showing revision info (it's for this build, not the old builds)
if (changeLogSet instanceof SubversionChangeLogSet) try {
Field f = SubversionChangeLogSet.class.getDeclaredField("revisionMap");
f.setAccessible(true);
f.set(changeLogSet, new HashMap(0));
} catch (Exception ex) { /* ignore */ }
if (changeLogSet instanceof SubversionChangeLogSet) {
try {
Field f = SubversionChangeLogSet.class.getDeclaredField("revisionMap");
f.setAccessible(true);
f.set(changeLogSet, new HashMap(0));
} catch (Exception ex) {
/* ignore */
}
}
result.put(getBuildNumber(file), changeLogSet);
}
return result;
Expand Down
Expand Up @@ -69,10 +69,13 @@ private void copyChangeLogs(AbstractBuild build) throws IOException, BuildExcept
}
// Copy changelog-history in this build, if any
File changeHistory = new File(build.getRootDir(), "changelog-history");
if (changeHistory.isDirectory()) {
checkDir(baseDir);
for (File file : changeHistory.listFiles()) {
Util.copyFile(file, new File(baseDir, file.getName()));
if (changeHistory != null && changeHistory.isDirectory()) {
File[] files = changeHistory.listFiles();
if (files != null) {
checkDir(baseDir);
for (File file : files) {
Util.copyFile(file, new File(baseDir, file.getName()));
}
}
copied = true;
}
Expand Down
Expand Up @@ -51,7 +51,7 @@ public void testPlugin() throws Exception {
// Now access the views for changelog-history display
WebClient wc = new WebClient();
HtmlPage page = wc.goTo("job/test-job/6/");
HtmlAnchor link = page.getFirstAnchorByText("Change Log History");
HtmlAnchor link = page.getAnchorByText("Change Log History");
assertNotNull("changelog-history link", link);
page = (HtmlPage)link.click();
String mainContent = page.getElementById("main-panel").asText();
Expand All @@ -71,7 +71,7 @@ public void testPlugin() throws Exception {

// Verify "More change log history" link on Recent Changes page
page = wc.goTo("job/test-job/changes");
link = page.getFirstAnchorByText("More change log history");
link = page.getAnchorByText("More change log history");
assertNotNull("'More change log history' link should be present on changes page", link);
}
}

0 comments on commit 722a8af

Please sign in to comment.