Skip to content

Commit

Permalink
JENKINS-44357 - add releaseEnvVar property to DeployArtifactsContext
Browse files Browse the repository at this point in the history
Add support for the optional releaseEnvVar property in the maven plugin
RedeployPublisher.

This property controls if the publisher should be skipped when the
environment variable value is ‘true’.
  • Loading branch information
cronik committed May 19, 2017
1 parent 405a95c commit 1c74f8e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/Home.md
Expand Up @@ -38,6 +38,8 @@ Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins
([#1028](https://github.com/jenkinsci/job-dsl-plugin/pull/1028))
* Enhanced support for the [Gradle Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Gradle+Plugin)
([JENKINS-44217](https://issues.jenkins-ci.org/browse/JENKINS-44217))
* Enhanced support for the [Maven Project Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Maven+Project+Plugin)
([JENKINS-44357](https://issues.jenkins-ci.org/browse/JENKINS-44357))
* Support for older versions of the
[HTML Publisher Plugin](https://wiki.jenkins-ci.org/display/JENKINS/HTML+Publisher+Plugin) is deprecated, see
[Migration](Migration#migrating-to-164)
Expand Down
Expand Up @@ -5,6 +5,7 @@ import javaposse.jobdsl.dsl.Context
class DeployArtifactsContext implements Context {
String repositoryUrl
String repositoryId
String releaseEnvVar
boolean uniqueVersion = true
boolean evenIfUnstable

Expand All @@ -26,6 +27,16 @@ class DeployArtifactsContext implements Context {
this.repositoryId = repositoryId
}

/**
* If the given environment variable is set to "true" the deploy step is skipped. Useful when using m2 release
* plugin.
*
* @since 1.64
*/
void releaseEnvVar(String releaseEnvVar) {
this.releaseEnvVar = releaseEnvVar
}

/**
* If set, assigns timestamp-based unique version number to the deployed artifacts, when their versions end with
* {@code -SNAPSHOT}. Defaults to {@code true}.
Expand Down
Expand Up @@ -24,6 +24,9 @@ class MavenPublisherContext extends PublisherContext {
if (context.repositoryUrl) {
url(context.repositoryUrl)
}
if (context.releaseEnvVar) {
releaseEnvVar(context.releaseEnvVar)
}
uniqueVersion(context.uniqueVersion)
evenIfUnstable(context.evenIfUnstable)
}
Expand Down
Expand Up @@ -28,16 +28,18 @@ class MavenPublisherContextSpec extends Specification {
context.deployArtifacts {
repositoryUrl('foo')
repositoryId('bar')
releaseEnvVar('var')
uniqueVersion(false)
evenIfUnstable()
}

then:
with(context.publisherNodes[0]) {
name() == 'hudson.maven.RedeployPublisher'
children().size() == 4
children().size() == 5
url[0].value() == 'foo'
id[0].value() == 'bar'
releaseEnvVar[0].value() == 'var'
uniqueVersion[0].value() == false
evenIfUnstable[0].value() == true
}
Expand Down

0 comments on commit 1c74f8e

Please sign in to comment.