Skip to content

Commit

Permalink
add pipeline aggregator plugin support
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilszymanski committed Nov 12, 2021
1 parent 748e590 commit 9305be2
Show file tree
Hide file tree
Showing 16 changed files with 354 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ scripts, including [[tests for DSL scripts|Testing DSL Scripts]] and [[IDE Suppo
Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins-ci.org/issues/?filter=15140).

## Release Notes
* 1.79 (unreleased)
* Added support for the [Pipeline Aggregator Plugin](https://plugins.jenkins.io/pipeline-aggregator-view)
* 1.78.1 (October 27 2021)
* Fix: Ensure API Viewer is packaged correctly into the built plugin ([JENKINS-66988](https://issues.jenkins.io/browse/JENKINS-66988))
* 1.78 (October 27 2021)
Expand Down
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') {
useCondensedTables()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pipelineAggregatorView('pipeline-aggregator-view') {
useScrollingCommits()
}
11 changes: 11 additions & 0 deletions job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/JobParent.groovy
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,16 @@ abstract class JobParent extends Script implements DslFactory {
processItem(name, Folder, closure)
}

/**
* @since 1.78
*/
@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.78
*/
@RequiresPlugin(id = 'pipeline-aggregator-view', minimumVersion = '1.8', failIfMissing = true)
PipelineAggregatorView pipelineAggregatorView(String name)

/**
* Creates or updates a view showing the history of pipelines with stage information.
*
* @since 1.78
*/
@RequiresPlugin(id = 'pipeline-aggregator-view', minimumVersion = '1.8', 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,16 @@ class NestedViewsContext extends AbstractExtensibleContext implements ViewFactor
processView(name, DashboardView, closure)
}

/**
* @since 1.78
*/
@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,87 @@
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)
}
}

/**
* 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)
}
}

@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,11 @@
<?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>
<useCondensedTables>false</useCondensedTables>
<onlyLastBuild>false</onlyLastBuild>
<useScrollingCommits>false</useScrollingCommits>
</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.8', 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.8', true)
}

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

Expand Down
Loading

0 comments on commit 9305be2

Please sign in to comment.