Skip to content

Commit

Permalink
[JENKINS-31911] Added support for Mantis plugin
Browse files Browse the repository at this point in the history
   Added TestCases and Docs for Mantis plugin

[JENKINS-31911] Added support for Mantis plugin
  • Loading branch information
v1v committed Dec 4, 2015
1 parent 0abcdd9 commit 443b909
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
@@ -0,0 +1,8 @@
job('example') {
publishers {
mantis {
keepNotePrivate(false)
recordChangelogToNote()
}
}
}
@@ -0,0 +1,22 @@
package javaposse.jobdsl.dsl.helpers.publisher

import javaposse.jobdsl.dsl.Context

class MantisContext implements Context {
boolean keepNotePrivate = false
boolean recordChangelogToNote = false

/**
* If set, it keeps note private. Defaults to {@code false}
*/
void keepNotePrivate(boolean keepNotePrivate = true) {
this.keepNotePrivate = keepNotePrivate
}

/**
* If set, records changelog to note. Defaults to {@code false}.
*/
void recordChangelogToNote(boolean recordChangelogToNote = true) {
this.recordChangelogToNote = recordChangelogToNote
}
}
Expand Up @@ -1738,6 +1738,22 @@ class PublisherContext extends AbstractExtensibleContext {
}
}

/*
* Updates relevant Mantis issues.
*
* @since 1.41
*/
@RequiresPlugin(id = 'mantis', minimumVersion = '0.26')
void mantis(@DslContext(MantisContext) Closure closure) {
MantisContext context = new MantisContext()
ContextHelper.executeInContext(closure, context)

publisherNodes << new NodeBuilder().'hudson.plugins.mantis.MantisIssueUpdater' {
keepNotePrivate(context.keepNotePrivate)
recordChangelog(context.recordChangelogToNote)
}
}

@SuppressWarnings('NoDef')
private static addStaticAnalysisContext(def nodeBuilder, StaticAnalysisContext context) {
nodeBuilder.with {
Expand Down
Expand Up @@ -5175,4 +5175,25 @@ class PublisherContextSpec extends Specification {
where:
value << [true, false]
}

def 'call mantis with all options'() {
when:
context.mantis {
keepNotePrivate(value)
recordChangelogToNote(value)
}

then:
context.publisherNodes.size() == 1
with(context.publisherNodes[0]) {
name() == 'hudson.plugins.mantis.MantisIssueUpdater'
children().size() == 2
keepNotePrivate[0].value() == value
recordChangelog[0].value() == value
}
1 * jobManagement.requireMinimumPluginVersion('mantis', '0.26')

where:
value << [true, false]
}
}

0 comments on commit 443b909

Please sign in to comment.