From 2d70d3a3b888adf7890165f767e0646b52f22a7f Mon Sep 17 00:00:00 2001 From: Donald Woods Date: Tue, 19 Jan 2016 15:19:58 -0500 Subject: [PATCH 1/2] Add DSL support for JaCoCo Line Coverage column via 'jacoco' method --- .../jobdsl/dsl/views/ColumnsContext.groovy | 10 ++++++++++ .../javaposse/jobdsl/dsl/views/ListViewSpec.groovy | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/views/ColumnsContext.groovy b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/views/ColumnsContext.groovy index 62bb838e7..eb1286fc4 100644 --- a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/views/ColumnsContext.groovy +++ b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/views/ColumnsContext.groovy @@ -148,4 +148,14 @@ class ColumnsContext extends AbstractContext { void progressBar() { columnNodes << new Node(null, 'org.jenkins.ci.plugins.progress__bar.ProgressBarColumn') } + + /** + * Adds a column showing JaCoCo Line Coverage. + * + * @since 1.43 + */ + @RequiresPlugin(id = 'jacoco-column', minimumVersion = '1.0') + void jacoco() { + columnNodes << new Node(null, 'hudson.plugins.jacococoveragecolumn.JaCoCoColumn') + } } diff --git a/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/views/ListViewSpec.groovy b/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/views/ListViewSpec.groovy index fb2732e7f..ab4566432 100644 --- a/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/views/ListViewSpec.groovy +++ b/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/views/ListViewSpec.groovy @@ -417,6 +417,20 @@ class ListViewSpec extends Specification { 1 * jobManagement.requireMinimumPluginVersion('custom-job-icon', '0.2') } + def 'jacoco column'() { + when: + view.columns { + jacoco() + } + + then: + Node root = view.node + root.columns.size() == 1 + root.columns[0].value().size() == 1 + root.columns[0].value()[0].name() == 'hudson.plugins.jacococoveragecolumn.JaCoCoColumn' + 1 * jobManagement.requireMinimumPluginVersion('jacoco-column', '1.0') + } + protected String getDefaultXml() { ''' From 66e5c2018a9467750c2bce8198d1383527d3292d Mon Sep 17 00:00:00 2001 From: Donald Woods Date: Tue, 19 Jan 2016 22:38:17 -0500 Subject: [PATCH 2/2] Fix plugin id for JaCoCo Line Coverage column support --- .../groovy/javaposse/jobdsl/dsl/views/ColumnsContext.groovy | 2 +- .../test/groovy/javaposse/jobdsl/dsl/views/ListViewSpec.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/views/ColumnsContext.groovy b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/views/ColumnsContext.groovy index eb1286fc4..d4fc0a955 100644 --- a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/views/ColumnsContext.groovy +++ b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/views/ColumnsContext.groovy @@ -154,7 +154,7 @@ class ColumnsContext extends AbstractContext { * * @since 1.43 */ - @RequiresPlugin(id = 'jacoco-column', minimumVersion = '1.0') + @RequiresPlugin(id = 'jacoco', minimumVersion = '1.0') void jacoco() { columnNodes << new Node(null, 'hudson.plugins.jacococoveragecolumn.JaCoCoColumn') } diff --git a/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/views/ListViewSpec.groovy b/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/views/ListViewSpec.groovy index ab4566432..fb6ffd45e 100644 --- a/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/views/ListViewSpec.groovy +++ b/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/views/ListViewSpec.groovy @@ -428,7 +428,7 @@ class ListViewSpec extends Specification { root.columns.size() == 1 root.columns[0].value().size() == 1 root.columns[0].value()[0].name() == 'hudson.plugins.jacococoveragecolumn.JaCoCoColumn' - 1 * jobManagement.requireMinimumPluginVersion('jacoco-column', '1.0') + 1 * jobManagement.requireMinimumPluginVersion('jacoco', '1.0') } protected String getDefaultXml() {