Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #712 from daspilker/JENKINS-29146
[JENKINS-29146] added support for the Dashboard View plugin
- Loading branch information
Showing
18 changed files
with
444 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
job-dsl-core/src/main/docs/examples/javaposse/jobdsl/dsl/DslFactory/dashboardView.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
dashboardView('example') { | ||
jobs { | ||
regex(/acme-.*/) | ||
} | ||
columns { | ||
status() | ||
weather() | ||
buildButton() | ||
} | ||
topPortlets { | ||
testStatisticsChart() | ||
} | ||
bottomPortlets { | ||
testStatisticsGrid() | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...es/javaposse/jobdsl/dsl/views/portlets/DashboardPortletContext/testStatisticsChart.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
dashboardView('example') { | ||
topPortlets { | ||
testStatisticsChart { | ||
displayName('Project A Test Stats') | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...les/javaposse/jobdsl/dsl/views/portlets/DashboardPortletContext/testStatisticsGrid.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
dashboardView('example') { | ||
rightPortlets { | ||
testStatisticsGrid { | ||
displayName('Project A Test Stats') | ||
skippedColor('7F7F7F') | ||
failureColor('FF0000') | ||
successColor('00FF00') | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/views/DashboardView.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package javaposse.jobdsl.dsl.views | ||
|
||
import javaposse.jobdsl.dsl.DslContext | ||
import javaposse.jobdsl.dsl.JobManagement | ||
import javaposse.jobdsl.dsl.views.portlets.DashboardPortletContext | ||
|
||
import static javaposse.jobdsl.dsl.ContextHelper.executeInContext | ||
|
||
class DashboardView extends ListView { | ||
DashboardView(JobManagement jobManagement) { | ||
super(jobManagement) | ||
} | ||
|
||
/** | ||
* Adds portlets to the top of the page. | ||
*/ | ||
void topPortlets(@DslContext(DashboardPortletContext) Closure closure) { | ||
addPortlets('topPortlets', closure) | ||
} | ||
|
||
/** | ||
* Adds portlets to the bottom of the page. | ||
*/ | ||
void bottomPortlets(@DslContext(DashboardPortletContext) Closure closure) { | ||
addPortlets('bottomPortlets', closure) | ||
} | ||
|
||
/** | ||
* Adds portlets to the left column. | ||
*/ | ||
void leftPortlets(@DslContext(DashboardPortletContext) Closure closure) { | ||
addPortlets('leftPortlets', closure) | ||
} | ||
|
||
/** | ||
* Adds portlets to the right column. | ||
*/ | ||
void rightPortlets(@DslContext(DashboardPortletContext) Closure closure) { | ||
addPortlets('rightPortlets', closure) | ||
} | ||
|
||
protected void addPortlets(String elementName, Closure closure) { | ||
DashboardPortletContext context = new DashboardPortletContext() | ||
executeInContext(closure, context) | ||
|
||
execute { | ||
context.portletNodes.each { node -> | ||
it / "$elementName" << node | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...l-core/src/main/groovy/javaposse/jobdsl/dsl/views/portlets/DashboardPortletContext.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package javaposse.jobdsl.dsl.views.portlets | ||
|
||
import javaposse.jobdsl.dsl.Context | ||
import javaposse.jobdsl.dsl.ContextHelper | ||
import javaposse.jobdsl.dsl.DslContext | ||
|
||
import java.security.SecureRandom | ||
|
||
class DashboardPortletContext implements Context { | ||
private static final Random RANDOM = new SecureRandom() | ||
|
||
protected final List<Node> portletNodes = [] | ||
|
||
/** | ||
* Adds a test statistics chart. | ||
*/ | ||
void testStatisticsChart(@DslContext(TestStatisticsChartContext) Closure closure = null) { | ||
TestStatisticsChartContext context = new TestStatisticsChartContext() | ||
ContextHelper.executeInContext(closure, context) | ||
|
||
portletNodes << new NodeBuilder().'hudson.plugins.view.dashboard.test.TestStatisticsChart' { | ||
id(generatePortletId()) | ||
name(context.displayName ?: '') | ||
} | ||
} | ||
|
||
/** | ||
* Adds a test statistics grid. | ||
*/ | ||
void testStatisticsGrid(@DslContext(TestStatisticsGridContext) Closure closure = null) { | ||
TestStatisticsGridContext context = new TestStatisticsGridContext() | ||
ContextHelper.executeInContext(closure, context) | ||
|
||
portletNodes << new NodeBuilder().'hudson.plugins.view.dashboard.test.TestStatisticsPortlet' { | ||
id(generatePortletId()) | ||
name(context.displayName ?: '') | ||
useBackgroundColors(context.useBackgroundColors) | ||
skippedColor(context.skippedColor ?: '') | ||
successColor(context.successColor ?: '') | ||
failureColor(context.failureColor ?: '') | ||
} | ||
} | ||
|
||
private static String generatePortletId() { | ||
"dashboard_portlet_${RANDOM.nextInt(32000)}" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ore/src/main/groovy/javaposse/jobdsl/dsl/views/portlets/TestStatisticsChartContext.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package javaposse.jobdsl.dsl.views.portlets | ||
|
||
import javaposse.jobdsl.dsl.Context | ||
|
||
class TestStatisticsChartContext implements Context { | ||
String displayName = 'Test Statistics Chart' | ||
|
||
/** | ||
* Sets the display name for the portlet. Defaults to {@code 'Test Statistics Chart'}. | ||
*/ | ||
void displayName(String displayName) { | ||
this.displayName = displayName | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...core/src/main/groovy/javaposse/jobdsl/dsl/views/portlets/TestStatisticsGridContext.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package javaposse.jobdsl.dsl.views.portlets | ||
|
||
import javaposse.jobdsl.dsl.Context | ||
|
||
class TestStatisticsGridContext implements Context { | ||
String displayName = 'Test Statistics Grid' | ||
boolean useBackgroundColors = false | ||
String skippedColor = 'FDB813' | ||
String successColor = '71E66D' | ||
String failureColor = 'E86850' | ||
|
||
/** | ||
* Sets the display name for the portlet. Defaults to {@code 'Test Statistics Grid'}. | ||
*/ | ||
void displayName(String displayName) { | ||
this.displayName = displayName | ||
} | ||
|
||
/** | ||
* If set, displays a colored background. Defaults to {@code false}. | ||
*/ | ||
void useBackgroundColors(boolean useBackgroundColors = true) { | ||
this.useBackgroundColors = useBackgroundColors | ||
} | ||
|
||
/** | ||
* Sets the color for skipped tests as hex value. Defaults to {@code 'FDB813'}. Sets {@code useBackgroundColors} to | ||
* {@code true}. | ||
*/ | ||
void skippedColor(String skippedColor) { | ||
useBackgroundColors() | ||
this.skippedColor = skippedColor | ||
} | ||
|
||
/** | ||
* Sets the color for successful tests as hex value. Defaults to {@code '71E66D'}. Sets {@code useBackgroundColors} | ||
* to {@code true}. | ||
*/ | ||
void successColor(String successColor) { | ||
useBackgroundColors() | ||
this.successColor = successColor | ||
} | ||
|
||
/** | ||
* Sets the color for failed tests as hex value. Defaults to {@code 'E86850'}. Sets {@code useBackgroundColors} to | ||
* {@code true}. | ||
*/ | ||
void failureColor(String failureColor) { | ||
useBackgroundColors() | ||
this.failureColor = failureColor | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
job-dsl-core/src/main/resources/javaposse/jobdsl/dsl/views/DashboardView-template.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<hudson.plugins.view.dashboard.Dashboard> | ||
<filterExecutors>false</filterExecutors> | ||
<filterQueue>false</filterQueue> | ||
<properties class="hudson.model.View$PropertyList"/> | ||
<jobNames> | ||
<comparator class="hudson.util.CaseInsensitiveComparator"/> | ||
</jobNames> | ||
<jobFilters/> | ||
<columns/> | ||
<recurse>false</recurse> | ||
<useCssStyle>false</useCssStyle> | ||
<includeStdJobList>false</includeStdJobList> | ||
<hideJenkinsPanels>false</hideJenkinsPanels> | ||
<leftPortletWidth>50%</leftPortletWidth> | ||
<rightPortletWidth>50%</rightPortletWidth> | ||
<leftPortlets/> | ||
<rightPortlets/> | ||
<topPortlets/> | ||
<bottomPortlets/> | ||
</hudson.plugins.view.dashboard.Dashboard> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/views/BuildMonitorViewSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.