Skip to content

Commit

Permalink
allow extensions for job view filters (#896)
Browse files Browse the repository at this point in the history
  • Loading branch information
daspilker authored Aug 15, 2016
1 parent 87c6eb1 commit 6f1f374
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins
([#882](https://github.com/jenkinsci/job-dsl-plugin/pull/882))
* Enhanced support for the [Groovy Postbuild Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Groovy+Postbuild+Plugin)
([#884](https://github.com/jenkinsci/job-dsl-plugin/pull/884))
* Allow extensions for job view filters
([#896](https://github.com/jenkinsci/job-dsl-plugin/pull/896))
* Updated [Structs Plugin](https://github.com/jenkinsci/structs-plugin) dependency to version 1.2
* Improved support for [[Automatically Generated DSL]]: print deprecation warnings and show deprecated methods in API
viewer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package javaposse.jobdsl.dsl.views

import javaposse.jobdsl.dsl.AbstractContext
import javaposse.jobdsl.dsl.AbstractExtensibleContext
import javaposse.jobdsl.dsl.ContextType
import javaposse.jobdsl.dsl.DslContext
import javaposse.jobdsl.dsl.JobManagement
import javaposse.jobdsl.dsl.RequiresPlugin
Expand All @@ -13,11 +14,17 @@ import javaposse.jobdsl.dsl.views.jobfilter.UnclassifiedJobsFilter

import static javaposse.jobdsl.dsl.ContextHelper.executeInContext

class JobFiltersContext extends AbstractContext {
@ContextType('hudson.views.ViewJobFilter')
class JobFiltersContext extends AbstractExtensibleContext {
List<Node> filterNodes = []

protected JobFiltersContext(JobManagement jobManagement) {
super(jobManagement)
super(jobManagement, null)
}

@Override
protected void addExtensionNode(Node node) {
filterNodes << node
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,24 @@ class ListViewSpec<T extends ListView> extends Specification {
1 * jobManagement.requireMinimumPluginVersion('release', '2.5.3')
}

def 'job filter extension'() {
setup:
jobManagement.callExtension('extension', null, JobFiltersContext) >> new Node(null, 'foo')

when:
view.jobFilters {
extension()
}

then:
def filters = view.node.jobFilters[0].value()
filters.size() == 1
with(filters[0]) {
name() == 'foo'
children().size() == 0
}
}

def 'recurse folders'() {
when:
view.recurse()
Expand Down

0 comments on commit 6f1f374

Please sign in to comment.