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

Add support for Pipeline Aggregator View #1209

Merged
merged 5 commits into from
Mar 22, 2023
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pipelineAggregatorView('pipeline-aggregator-view') {
filterRegex('.*Pipeline')
onlyLastBuild()
useCondensedTables()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pipelineAggregatorView('pipeline-aggregator-view') {
buildHistorySize(10)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pipelineAggregatorView('pipeline-aggregator-view') {
description('View description')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pipelineAggregatorView('pipeline-aggregator-view') {
filterRegex('.*Pipeline')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pipelineAggregatorView('pipeline-aggregator-view') {
fontSize(10)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pipelineAggregatorView('pipeline-aggregator-view') {
onlyLastBuild()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pipelineAggregatorView('pipeline-aggregator-view') {
showBuildDuration(false)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pipelineAggregatorView('pipeline-aggregator-view') {
useCondensedTables()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pipelineAggregatorView('pipeline-aggregator-view') {
useScrollingCommits()
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import javaposse.jobdsl.dsl.views.DashboardView
import javaposse.jobdsl.dsl.views.DeliveryPipelineView
import javaposse.jobdsl.dsl.views.ListView
import javaposse.jobdsl.dsl.views.NestedView
import javaposse.jobdsl.dsl.views.PipelineAggregatorView
import javaposse.jobdsl.dsl.views.SectionedView

import static javaposse.jobdsl.dsl.Preconditions.checkNotNull
Expand Down Expand Up @@ -174,6 +175,15 @@ abstract class JobParent extends Script implements DslFactory {
processItem(name, Folder, closure)
}

/**
* @since 1.83
*/
@Override
PipelineAggregatorView pipelineAggregatorView(
String name, @DslContext(PipelineAggregatorView) Closure closure = null) {
processView(name, PipelineAggregatorView, closure)
}

@Override
void configFiles(@DslContext(ConfigFilesContext) Closure closure) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import javaposse.jobdsl.dsl.views.DashboardView
import javaposse.jobdsl.dsl.views.DeliveryPipelineView
import javaposse.jobdsl.dsl.views.ListView
import javaposse.jobdsl.dsl.views.NestedView
import javaposse.jobdsl.dsl.views.PipelineAggregatorView
import javaposse.jobdsl.dsl.views.SectionedView

/**
Expand Down Expand Up @@ -129,4 +130,21 @@ interface ViewFactory extends Context {
*/
@RequiresPlugin(id = 'dashboard-view', minimumVersion = '2.9.7', failIfMissing = true)
DashboardView dashboardView(String name, @DslContext(DashboardView) Closure closure)

/**
* Creates or updates a view showing the history of pipelines with stage information.
*
* @see #pipelineAggregatorView(java.lang.String, groovy.lang.Closure)
* @since 1.83
*/
@RequiresPlugin(id = 'pipeline-aggregator-view', minimumVersion = '1.15', failIfMissing = true)
PipelineAggregatorView pipelineAggregatorView(String name)

/**
* Creates or updates a view showing the history of pipelines with stage information.
*
* @since 1.83
*/
@RequiresPlugin(id = 'pipeline-aggregator-view', minimumVersion = '1.15', failIfMissing = true)
PipelineAggregatorView pipelineAggregatorView(String name, @DslContext(PipelineAggregatorView) Closure closure)
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ class NestedViewsContext extends AbstractExtensibleContext implements ViewFactor
processView(name, DashboardView, closure)
}

/**
* @since 1.83
*/
@Override
PipelineAggregatorView pipelineAggregatorView(
String name, @DslContext(PipelineAggregatorView) Closure closure = null) {
processView(name, PipelineAggregatorView, closure)
}

@Override
protected void addExtensionNode(Node node) {
views << new View(jobManagement, node['name'].text()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package javaposse.jobdsl.dsl.views

import javaposse.jobdsl.dsl.JobManagement
import javaposse.jobdsl.dsl.NoDoc
import javaposse.jobdsl.dsl.View

import static javaposse.jobdsl.dsl.Preconditions.checkArgument
import static javaposse.jobdsl.dsl.Preconditions.checkNotNullOrEmpty

class PipelineAggregatorView extends View {
PipelineAggregatorView(JobManagement jobManagement, String name) {
super(jobManagement, name)
}

/**
* Set the number of most recent builds to display. Defaults to {@code 16}.
*/
void buildHistorySize(int buildHistorySize) {
checkArgument(buildHistorySize > 0, 'buildHistorySize must be positive integer')

configure {
it / methodMissing('buildHistorySize', buildHistorySize)
}
}

/**
* Set regular expression used for filtering pipelines to be displayed.
*/
void filterRegex(String filterRegex) {
checkNotNullOrEmpty(filterRegex, 'filterRegex must be specified')

configure {
it / methodMissing('filterRegex', filterRegex)
}
}

/**
* Set font size. Defaults to {@code 16}.
*/
void fontSize(int fontSize) {
checkArgument(fontSize > 0, 'fontSize must be positive integer')

configure {
it / methodMissing('fontSize', fontSize)
}
}

/**
* Set refresh interval size. Defaults to {@code 15}.
*/
void refreshInterval(int refreshInterval) {
checkArgument(refreshInterval > 0, 'refreshInterval must be positive integer')

configure {
it / methodMissing('refreshInterval', refreshInterval)
}
}

/**
* Display only last pipeline build. Defaults to {@code false}.
*/
void onlyLastBuild(boolean onlyLastBuild = true) {
configure {
it / methodMissing('onlyLastBuild', onlyLastBuild)
}
}

/**
* Use condensed tables. Defaults to {@code false}.
*/
void useCondensedTables(boolean useCondensedTables = true) {
configure {
it / methodMissing('useCondensedTables', useCondensedTables)
}
}

/**
* Use scrolling commits. Defaults to {@code false}.
*/
void useScrollingCommits(boolean useScrollingCommits = true) {
configure {
it / methodMissing('useScrollingCommits', useScrollingCommits)
}
}

/**
* Show commit info. Defaults to {@code true}.
*/
void showCommitInfo(boolean showCommitInfo = true) {
configure {
it / methodMissing('showCommitInfo', showCommitInfo)
}
}

/**
* Show build number. Defaults to {@code true}.
*/
void showBuildNumber(boolean showBuildNumber = true) {
configure {
it / methodMissing('showBuildNumber', showBuildNumber)
}
}

/**
* Show build time. Defaults to {@code true}.
*/
void showBuildTime(boolean showBuildTime = true) {
configure {
it / methodMissing('showBuildTime', showBuildTime)
}
}

/**
* Show build duration. Defaults to {@code true}.
*/
void showBuildDuration(boolean showBuildDuration = true) {
configure {
it / methodMissing('showBuildDuration', showBuildDuration)
}
}

@Override
@NoDoc
void filterBuildQueue(boolean filterBuildQueue = true) {
super.filterBuildQueue(filterBuildQueue)
}

@Override
@NoDoc
void filterExecutors(boolean filterExecutors = true) {
super.filterExecutors(filterExecutors)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.1" encoding="UTF-8"?>
<com.ooyala.jenkins.plugins.pipelineaggregatorview.PipelineAggregator>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList"/>
<fontSize>16</fontSize>
<buildHistorySize>16</buildHistorySize>
<refreshInterval>15</refreshInterval>
<useCondensedTables>false</useCondensedTables>
<onlyLastBuild>false</onlyLastBuild>
<useScrollingCommits>false</useScrollingCommits>
<showCommitInfo>true</showCommitInfo>
<showBuildNumber>true</showBuildNumber>
<showBuildTime>true</showBuildTime>
<showBuildDuration>true</showBuildDuration>
</com.ooyala.jenkins.plugins.pipelineaggregatorview.PipelineAggregator>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import javaposse.jobdsl.dsl.views.DashboardView
import javaposse.jobdsl.dsl.views.DeliveryPipelineView
import javaposse.jobdsl.dsl.views.ListView
import javaposse.jobdsl.dsl.views.NestedView
import javaposse.jobdsl.dsl.views.PipelineAggregatorView
import javaposse.jobdsl.dsl.views.SectionedView
import spock.lang.Specification

Expand Down Expand Up @@ -247,6 +248,31 @@ class JobParentSpec extends Specification {
1 * jobManagement.requireMinimumPluginVersion('cloudbees-folder', '5.14', true)
}

def 'pipeline aggregator view'() {
when:
View view = parent.pipelineAggregatorView('test') {
description('foo')
}

then:
view.name == 'test'
view instanceof PipelineAggregatorView
parent.referencedViews.contains(view)
view.node.description[0].text() == 'foo'
1 * jobManagement.requireMinimumPluginVersion('pipeline-aggregator-view', '1.15', true)
}

def 'pipeline aggregator view without closure'() {
when:
View view = parent.pipelineAggregatorView('test')

then:
view.name == 'test'
view instanceof PipelineAggregatorView
parent.referencedViews.contains(view)
1 * jobManagement.requireMinimumPluginVersion('pipeline-aggregator-view', '1.15', true)
}

def 'readFileInWorkspace from seed job'() {
jobManagement.readFileInWorkspace('foo.txt') >> 'hello'

Expand Down
Loading