Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display Aggregate/Summary Widget of Successful Builds #336

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Simple, right? :-) You can have as many Build Monitor Views as you want - the mo
![Three columns view](docs/2_Three_columns_view.png)
![Supports Claim and Build Failure Analyzer plugins](docs/3_Two_columns_view_with_claim_and_build_failure_analyzer_plugins.png)
![Colour-blind mode](docs/4_Colour_blind_mode.png)
![All-Builds-Passing Summary Badge](docs/5_All_builds_passing_fullscreen_summary_widget.png)
![Not-All-Builds-Passing Summary Badge](docs/6_Not_all_builds_passing_summary_widget.png)

## Roadmap and work in progress

Expand Down Expand Up @@ -98,6 +100,7 @@ You have several options here:

1. **review the granularity of your jobs**: If you have too many low-level jobs displayed on one screen, consider consolidating them using [Promoted Builds Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Promoted+Builds+Plugin) or [MultiJob Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin)
1. **use job filters**: Build Monitor supports Jenkins [View Job Filters Plugin](https://wiki.jenkins-ci.org/display/JENKINS/View+Job+Filters), if you have it installed
1. collapse successful builds: if you only want to see the jobs that aren't passing, consider collapsing all successful jobs into a single summary widget
1. get a bigger screen ...

### Red and green colours are lovely, but I'm colour blind ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,14 @@ public ProjectWidget(String projectOfInterest) {
this.projectOfInterest = projectOfInterest;
}

public Question<String> fullScreenSummaryBadgeDescription() {
return new CollapseFill();
}

public Question<String> partialScreenSummaryBadgeDescription() {
return new CollapsePartial();
}

private final String projectOfInterest;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.smartcodeltd.jenkinsci.plugins.build_monitor.questions.project_widget;

import com.smartcodeltd.jenkinsci.plugins.build_monitor.user_interface.BuildMonitorDashboard;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Question;
import net.serenitybdd.screenplay.annotations.Subject;
import net.serenitybdd.screenplay.questions.Text;
import net.serenitybdd.screenplay.targets.Target;

@Subject("fullscreen badge")
public class CollapseFill implements Question<String> {

@Override
public String answeredBy(Actor actor) {
Target fillCollapse = BuildMonitorDashboard.Collapse_Fill;

return Text.of(fillCollapse).viewedBy(actor).resolve();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.smartcodeltd.jenkinsci.plugins.build_monitor.questions.project_widget;

import com.smartcodeltd.jenkinsci.plugins.build_monitor.user_interface.BuildMonitorDashboard;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Question;
import net.serenitybdd.screenplay.annotations.Subject;
import net.serenitybdd.screenplay.questions.Text;
import net.serenitybdd.screenplay.targets.Target;

import static net.serenitybdd.screenplay.questions.WebElementQuestion.stateOf;

@Subject("partial badge")
public class CollapsePartial implements Question<String> {

@Override
public String answeredBy(Actor actor) {
Target partialCollapse = BuildMonitorDashboard.Collapse_Partial;

return Text.of(partialCollapse).viewedBy(actor).resolve();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.smartcodeltd.jenkinsci.plugins.build_monitor.tasks.configuration;

import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Task;
import net.serenitybdd.screenplay.jenkins.actions.Choose;
import net.serenitybdd.screenplay.jenkins.user_interface.ViewConfigurationPage;
import net.thucydides.core.annotations.Step;

import static net.serenitybdd.screenplay.Tasks.instrumented;

public class CollapseSuccessfulBuilds implements Task {

public static Task usingCollapseSuccessfulBuildsCheckbox() {
return instrumented(CollapseSuccessfulBuilds.class);
}

@Step("{0} clicks the Collapse Successful Builds checkbox")
@Override
public <T extends Actor> void performAs(T actor) {
actor.attemptsTo(
Choose.the(ViewConfigurationPage.Apply_Collapse_Successful_Builds)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public class BuildMonitorDashboard {
public static final Target Project_Widget_Badges = Target.the("Project Widget Badges").locatedBy("//li[header/h2[.='{0}']]//*[@class='badges']");
public static final Target Project_Widget_Pipeline_Stages = Target.the("Project Widget Builds").locatedBy("//li[header/h2[.='{0}']]//*[contains(@class, 'build-stages')]");

public static final Target Collapse_Fill = Target.the("Success Summary Badge").locatedBy("//*[@id=\"full-summary-badge\"]/p");
public static final Target Collapse_Partial = Target.the("Success Summary Badge").locatedBy("//*[@id=\"partial-summary-badge\"]/header/h2[2]");

public static final Target Control_Panel = Target.the("Control Panel").locatedBy("//label[@for='settings-toggle']");
public static final Target Show_Badges = Target.the("Show Badges Toggle").locatedBy("//input[@id='settings-show-badges']");
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
public class ViewConfigurationPage {
public static final Target Recurse_In_Subfolders = Target.the("the 'Recurse in subfolders' option").locatedBy("#recurse");
public static final Target Use_Regular_Expression = Checkbox.withLabel("Use a regular expression to include jobs into the view");
public static final Target Apply_Collapse_Successful_Builds = Target.the("the 'Collapse Successful Builds' option").locatedBy("#collapse");
public static final Target Regular_Expression = Target.the("the 'Regular expression' field").located(By.name("includeRegex"));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package features;
import com.smartcodeltd.jenkinsci.plugins.build_monitor.questions.ProjectWidget;
import com.smartcodeltd.jenkinsci.plugins.build_monitor.tasks.ConfigureEmptyBuildMonitorView;
import com.smartcodeltd.jenkinsci.plugins.build_monitor.tasks.CreateABuildMonitorView;
import com.smartcodeltd.jenkinsci.plugins.build_monitor.tasks.configuration.CollapseSuccessfulBuilds;
import com.smartcodeltd.jenkinsci.plugins.build_monitor.tasks.configuration.DisplayAllProjects;
import environment.JenkinsSandbox;
import net.serenitybdd.integration.jenkins.JenkinsInstance;
import net.serenitybdd.junit.runners.SerenityRunner;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.abilities.BrowseTheWeb;
import net.serenitybdd.screenplay.jenkins.HaveAFailingProjectCreated;
import net.serenitybdd.screenplay.jenkins.HaveASuccessfulProjectCreated;
import net.serenitybdd.screenplayx.actions.Navigate;
import net.thucydides.core.annotations.Managed;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;

import static net.serenitybdd.screenplay.GivenWhenThen.*;
import static org.hamcrest.Matchers.is;

@RunWith(SerenityRunner.class)
public class BVMCollapseSummaryBadgeTest {

Actor sophie = Actor.named("Sophie");

@Managed public WebDriver herBrowser;

@Rule public JenkinsInstance jenkins = JenkinsSandbox.configure().create();

@Before
public void actorCanBrowseTheWeb() {
sophie.can(BrowseTheWeb.with(herBrowser));
}

@Test
public void one_of_one_tests_pass_full_screen_summary_badge() throws Exception {

givenThat(sophie).wasAbleTo(
Navigate.to(jenkins.url()),
HaveASuccessfulProjectCreated.called("My Project")
);

when(sophie).attemptsTo(
CreateABuildMonitorView.called("Build Monitor"),
ConfigureEmptyBuildMonitorView.to(CollapseSuccessfulBuilds.usingCollapseSuccessfulBuildsCheckbox(),DisplayAllProjects.usingARegularExpression())
);

then(sophie).should(seeThat(ProjectWidget.of("My Project").fullScreenSummaryBadgeDescription(), is("all builds passed")));

}

@Test
public void one_of_two_tests_pass_partial_screen_summary_badge() throws Exception {

givenThat(sophie).wasAbleTo(
Navigate.to(jenkins.url()),
HaveASuccessfulProjectCreated.called("Successful Project"),
Navigate.to(jenkins.url()),
HaveAFailingProjectCreated.called("Failing Project")
);

when(sophie).attemptsTo(
CreateABuildMonitorView.called("Build Monitor"),
ConfigureEmptyBuildMonitorView.to(CollapseSuccessfulBuilds.usingCollapseSuccessfulBuildsCheckbox(),DisplayAllProjects.usingARegularExpression())
);

then(sophie).should(seeThat(ProjectWidget.of("").partialScreenSummaryBadgeDescription(), is("1/2 job(s) passing")));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
public class BuildMonitorView extends ListView {
@Extension
public static final BuildMonitorDescriptor descriptor = new BuildMonitorDescriptor();

private boolean collapseToSummaryBadge;
private String title;

/**
Expand All @@ -64,6 +64,8 @@ public BuildMonitorView(String name, String title) {
super(name);

this.title = title;

this.collapseToSummaryBadge = false;
}

@SuppressWarnings("unused") // used in .jelly
Expand Down Expand Up @@ -108,6 +110,18 @@ public boolean collectAnonymousUsageStatistics() {
return descriptor.getPermissionToCollectAnonymousUsageStatistics();
}

@SuppressWarnings("unused") // used in the configure-entries.jelly form
public boolean getCollapseToSummaryBadge(){
return collapseToSummaryBadge;
}

public boolean getCollapseToSummaryBadgeValue(String str){
if(str == null){
return false;
}
return true;
}

@Override
protected void submit(StaplerRequest req) throws ServletException, IOException, FormException {
super.submit(req);
Expand All @@ -118,6 +132,7 @@ protected void submit(StaplerRequest req) throws ServletException, IOException,

String requestedOrdering = req.getParameter("order");
title = req.getParameter("title");
collapseToSummaryBadge = getCollapseToSummaryBadgeValue(req.getParameter("collapse"));

currentConfig().setDisplayCommitters(json.optBoolean("displayCommitters", true));
currentConfig().setBuildFailureAnalyzerDisplayedField(req.getParameter("buildFailureAnalyzerDisplayedField"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
</select>
</f:entry>

<f:entry title="${%Collapse Successful Builds}" field="collapse">
<f:checkbox name="collapse" checked="${it.collapseToSummaryBadge}" id="collapse"/>
</f:entry>

<f:entry title="${%Recurse in subfolders}" field="recurse">
<f:checkbox id="recurse"/>
</f:entry>
Expand Down
Loading