diff --git a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView.java b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView.java index 12e065443..ed0194fa4 100644 --- a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView.java +++ b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView.java @@ -92,8 +92,13 @@ public String currentbuildFailureAnalyzerDisplayedField() { } @SuppressWarnings("unused") // used in the configure-entries.jelly form - public boolean isDisplayCommitters() { - return currentConfig().shouldDisplayCommitters(); + public boolean isDisplayCommittersOnBuildFailure() { + return currentConfig().shouldDisplayCommittersOnBuildFailure(); + } + + @SuppressWarnings("unused") // used in the configure-entries.jelly form + public boolean isDisplayCommittersOnFixedBuild() { + return currentConfig().shouldDisplayCommittersOnFixedBuild(); } private static final BuildMonitorInstallation installation = new BuildMonitorInstallation(); @@ -119,9 +124,10 @@ protected void submit(StaplerRequest req) throws ServletException, IOException, String requestedOrdering = req.getParameter("order"); title = req.getParameter("title"); - currentConfig().setDisplayCommitters(json.optBoolean("displayCommitters", true)); + currentConfig().setDisplayCommittersOnBuildFailure(json.optBoolean("displayCommittersOnBuildFailure", true)); + currentConfig().setDisplayCommittersOnFixedBuild(json.optBoolean("displayCommittersOnFixedBuild", true)); currentConfig().setBuildFailureAnalyzerDisplayedField(req.getParameter("buildFailureAnalyzerDisplayedField")); - + try { currentConfig().setOrder(orderIn(requestedOrdering)); } catch (Exception e) { diff --git a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/Config.java b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/Config.java index c10b3296f..6f69a0170 100644 --- a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/Config.java +++ b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/Config.java @@ -10,9 +10,10 @@ public class Config { - private boolean displayCommitters; + private boolean displayCommittersOnBuildFailure; + private boolean displayCommittersOnFixedBuild; private BuildFailureAnalyzerDisplayedField buildFailureAnalyzerDisplayedField; - + public static Config defaultConfig() { return new Config(); } @@ -40,13 +41,21 @@ public BuildFailureAnalyzerDisplayedField getBuildFailureAnalyzerDisplayedField( public void setBuildFailureAnalyzerDisplayedField(String buildFailureAnalyzerDisplayedField) { this.buildFailureAnalyzerDisplayedField = BuildFailureAnalyzerDisplayedField.valueOf(buildFailureAnalyzerDisplayedField); } - - public boolean shouldDisplayCommitters() { - return getOrElse(displayCommitters, true); + + public boolean shouldDisplayCommittersOnBuildFailure() { + return getOrElse(displayCommittersOnBuildFailure, true); + } + + public void setDisplayCommittersOnBuildFailure(boolean flag) { + this.displayCommittersOnBuildFailure = flag; + } + + public boolean shouldDisplayCommittersOnFixedBuild() { + return getOrElse(displayCommittersOnFixedBuild, false); } - public void setDisplayCommitters(boolean flag) { - this.displayCommitters = flag; + public void setDisplayCommittersOnFixedBuild(boolean flag) { + this.displayCommittersOnFixedBuild = flag; } @Override diff --git a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/JobViews.java b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/JobViews.java index 9b0c3accc..a5dd68d13 100644 --- a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/JobViews.java +++ b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/JobViews.java @@ -31,7 +31,7 @@ public JobView viewOf(Job job) { List viewFeatures = newArrayList(); // todo: a more elegant way of assembling the features would be nice - viewFeatures.add(new HasHeadline(new HeadlineConfig(config.shouldDisplayCommitters()))); + viewFeatures.add(new HasHeadline(new HeadlineConfig(config.shouldDisplayCommittersOnBuildFailure(), config.shouldDisplayCommittersOnFixedBuild()))); viewFeatures.add(new KnowsLastCompletedBuildDetails()); viewFeatures.add(new KnowsCurrentBuildsDetails()); diff --git a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineConfig.java b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineConfig.java index a1cbad048..13b99a4ed 100644 --- a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineConfig.java +++ b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineConfig.java @@ -4,9 +4,12 @@ * @author Jan Molak */ public class HeadlineConfig { - public final boolean displayCommitters; + public final boolean displayCommittersOnBuildFailure; + public final boolean displayCommittersOnFixedBuild; - public HeadlineConfig(boolean displayCommitters) { - this.displayCommitters = displayCommitters; + public HeadlineConfig(boolean displayCommittersOnBuildFailure, boolean displayCommittersOnFixedBuild) { + + this.displayCommittersOnBuildFailure = displayCommittersOnBuildFailure; + this.displayCommittersOnFixedBuild = displayCommittersOnFixedBuild; } } diff --git a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfAborted.java b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfAborted.java index 47f9e2cfe..94694731f 100644 --- a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfAborted.java +++ b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfAborted.java @@ -35,7 +35,7 @@ public Headline asJson() { private String text(BuildViewModel build) { Optional interruption = build.detailsOf(InterruptedBuildAction.class); - if (config.displayCommitters && interruption.isPresent()) { + if (config.displayCommittersOnBuildFailure && interruption.isPresent()) { Optional username = userResponsibleFor(interruption.get()); diff --git a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfExecuting.java b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfExecuting.java index db06677b9..30e15a153 100644 --- a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfExecuting.java +++ b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfExecuting.java @@ -37,7 +37,7 @@ private String text(BuildViewModel build) { } private Set committersOf(BuildViewModel build) { - return config.displayCommitters + return config.displayCommittersOnBuildFailure ? build.committers() : Sets.newHashSet(); } diff --git a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfFailing.java b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfFailing.java index 96930e6c1..f23e20c3c 100644 --- a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfFailing.java +++ b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfFailing.java @@ -80,7 +80,7 @@ private List failedBuildsSince(BuildViewModel build) { } private Set responsibleFor(BuildViewModel build) { - return config.displayCommitters + return config.displayCommittersOnBuildFailure ? build.culprits() : Sets.newHashSet(); } diff --git a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfFixed.java b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfFixed.java index d8d79fd16..5e6672e53 100644 --- a/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfFixed.java +++ b/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/headline/HeadlineOfFixed.java @@ -24,7 +24,7 @@ public HeadlineOfFixed(JobView job, HeadlineConfig config) { @Override public boolean isApplicableTo(JobView job) { - return didTheJobJustGetFixedWith(job.lastCompletedBuild()); + return didTheJobJustGetFixedWith(job.lastCompletedBuild()) && config.displayCommittersOnFixedBuild; } @Override @@ -35,7 +35,7 @@ public Headline asJson() { private String textFor(BuildViewModel lastBuild) { return Lister.describe( - "Back in the green!", + "", "Fixed after %s committed their changes :-)", newLinkedList(committersOf(lastBuild)) ); @@ -51,7 +51,7 @@ private boolean previousFailed(BuildViewModel build) { } private Set committersOf(BuildViewModel build) { - return config.displayCommitters + return config.displayCommittersOnFixedBuild ? build.committers() : Sets.newHashSet(); } diff --git a/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/configure-entries.jelly b/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/configure-entries.jelly index 3c39f5625..7c3b1555d 100644 --- a/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/configure-entries.jelly +++ b/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/configure-entries.jelly @@ -71,8 +71,12 @@ - - + + + + + + diff --git a/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/help-displayCommitters.html b/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/help-displayCommitters.html index 50fb770f4..f62b5af0f 100644 --- a/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/help-displayCommitters.html +++ b/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/help-displayCommitters.html @@ -4,10 +4,6 @@ You can use it to quickly find out who might know the most about the problem and need help fixing it.

-

- This feature works the other way around too! If someone fixes a broken build, - it's their identifier that gets to appear on the screen. -

Did you know that when a broken build is claimed, diff --git a/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugin/assetbundler/PathToAssetTest.java b/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugin/assetbundler/PathToAssetTest.java index 8e59235c8..297e9e1a7 100644 --- a/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugin/assetbundler/PathToAssetTest.java +++ b/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugin/assetbundler/PathToAssetTest.java @@ -7,8 +7,7 @@ import java.net.MalformedURLException; import java.net.URL; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; +import static junit.framework.TestCase.assertTrue; public class PathToAssetTest { @@ -17,8 +16,10 @@ public void combines_base_resource_url_given_by_jenkins_and_a_path_to_the_asset( URL base = baseResourceUrlGivenByJenkins("file:///opt/jenkins/plugins/build-monitor-plugin/"); PathToAsset path = new PathToAsset(base, "less/index.less"); - - assertThat(absolute(path), is("/opt/jenkins/plugins/build-monitor-plugin/less/index.less")); + //Tweaking it to be able to run on Windows + String actualValue = absolute(path).replace("\\", "/"); + String expectedValue = "/opt/jenkins/plugins/build-monitor-plugin/less/index.less"; + assertTrue("\nActual: " + actualValue + " \n does not contain expected value : " + expectedValue, actualValue.contains(expectedValue)); } @Test @@ -26,8 +27,10 @@ public void works_with_unc_paths_on_windows() throws Exception { URL base = baseResourceUrlGivenByJenkins("file://server/jenkins/plugins/build-monitor-plugin/"); PathToAsset path = new PathToAsset(base, "less/index.less"); - - assertThat(absolute(path), is("/server/jenkins/plugins/build-monitor-plugin/less/index.less")); + //Tweaking it to be able to run on Windows + String actualValue = absolute(path).replace("\\", "/"); + String expectedValue = "/server/jenkins/plugins/build-monitor-plugin/less/index.less"; + assertTrue("\nActual: " + actualValue + " \n does not contain expected value : " + expectedValue, actualValue.contains(expectedValue)); } @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingAbortedBuildDetails.java b/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingAbortedBuildDetails.java index f91bcde40..e974bc188 100644 --- a/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingAbortedBuildDetails.java +++ b/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingAbortedBuildDetails.java @@ -38,11 +38,11 @@ public void should_tell_if_a_build_was_aborted() throws Exception { // -- private Feature hasHeadlineThatShowsCommitters() { - return new HasHeadline(new HeadlineConfig(true)); + return new HasHeadline(new HeadlineConfig(true, false)); } private Feature hasHeadlineThatDoesNotShowCommitters() { - return new HasHeadline(new HeadlineConfig(false)); + return new HasHeadline(new HeadlineConfig(false, false)); } private String headlineOf(JobView job) { diff --git a/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingFailedBuildDetailsTest.java b/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingFailedBuildDetailsTest.java index 805771852..3c93d2c5f 100644 --- a/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingFailedBuildDetailsTest.java +++ b/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingFailedBuildDetailsTest.java @@ -81,11 +81,11 @@ public void should_tell_the_number_of_broken_builds_since_the_last_build_broken_ // -- private Feature hasHeadlineThatShowsCommitters() { - return new HasHeadline(new HeadlineConfig(true)); + return new HasHeadline(new HeadlineConfig(true, false)); } private Feature hasHeadlineThatDoesNotShowCommitters() { - return new HasHeadline(new HeadlineConfig(false)); + return new HasHeadline(new HeadlineConfig(false, false)); } private String headlineOf(JobView job) { diff --git a/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingFixedBuildDetailsTest.java b/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingFixedBuildDetailsTest.java index 0282930bf..dd1b9af29 100644 --- a/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingFixedBuildDetailsTest.java +++ b/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingFixedBuildDetailsTest.java @@ -37,7 +37,7 @@ public void should_congratulate_anonymously_if_broken_build_was_fixed_without_kn a(job().whereTheLast(build().succeededThanksTo()). andThePrevious(build().wasBrokenBy("Daniel", "Ben"))))); - assertThat(headlineOf(view), is("Back in the green!")); + assertThat(headlineOf(view), is("")); } @Test @@ -46,7 +46,7 @@ public void should_congratulate_anonymously_when_the_build_is_fixed_but_the_comm a(job().whereTheLast(build().succeededThanksTo("Adam")). andThePrevious(build().wasBrokenBy("Daniel", "Ben"))))); - assertThat(headlineOf(view), is("Back in the green!")); + assertThat(headlineOf(view), is("")); } @Test @@ -69,11 +69,11 @@ public void should_not_congratulate_if_no_failure_before() throws Exception { // -- private Feature hasHeadlineThatShowsCommitters() { - return new HasHeadline(new HeadlineConfig(true)); + return new HasHeadline(new HeadlineConfig(true, true)); } private Feature hasHeadlineThatDoesNotShowCommitters() { - return new HasHeadline(new HeadlineConfig(false)); + return new HasHeadline(new HeadlineConfig(false, false)); } private String headlineOf(JobView job) { diff --git a/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingRunningBuildDetailsTest.java b/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingRunningBuildDetailsTest.java index 82ad4d68a..fd33377be 100644 --- a/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingRunningBuildDetailsTest.java +++ b/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineShowingRunningBuildDetailsTest.java @@ -49,11 +49,11 @@ public void should_not_tell_whose_changes_are_being_built_if_commiters_are_not_t // -- private Feature hasHeadlineThatShowsCommitters() { - return new HasHeadline(new HeadlineConfig(true)); + return new HasHeadline(new HeadlineConfig(true, false)); } private Feature hasHeadlineThatDoesNotShowCommitters() { - return new HasHeadline(new HeadlineConfig(false)); + return new HasHeadline(new HeadlineConfig(false, false)); } private String headlineOf(JobView job) { diff --git a/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineWhichShowsNothingTest.java b/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineWhichShowsNothingTest.java index ca1876511..917d850af 100644 --- a/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineWhichShowsNothingTest.java +++ b/build-monitor-plugin/src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/features/HasHeadlineWhichShowsNothingTest.java @@ -22,7 +22,7 @@ public void should_say_nothing_if_no_builds_were_executed() throws Exception { // -- private Feature hasHeadlineThatShowsCommitters() { - return new HasHeadline(new HeadlineConfig(true)); + return new HasHeadline(new HeadlineConfig(true, false)); } private String headlineOf(JobView job) {