Skip to content
Permalink
Browse files

enhanced support for the GitLab Plugin and deprecated support for old…

…er versions

[FIXES JENKINS-41485]
  • Loading branch information
daspilker committed Jan 29, 2017
1 parent 62306c7 commit c3d89c37971fd2eba301f967ab45e155ffad53c6
@@ -32,6 +32,8 @@ Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins
([JENKINS-33630](https://issues.jenkins-ci.org/browse/JENKINS-33630),
[JENKINS-39754](https://issues.jenkins-ci.org/browse/JENKINS-39754),
[JENKINS-40719](https://issues.jenkins-ci.org/browse/JENKINS-40719))
* Enhanced support for the [GitLab Plugin](https://wiki.jenkins-ci.org/display/JENKINS/GitLab+Plugin)
([JENKINS-41485](https://issues.jenkins-ci.org/browse/JENKINS-41485))
* Fixed a problem with the plugin's dependencies
([JENKINS-41001](https://issues.jenkins-ci.org/browse/JENKINS-41001))
* Improved error message for invalid enum values
@@ -41,6 +43,8 @@ Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins
* The syntax for creating config files is changing, see [Migration](Migration#migrating-to-158)
* Most classes and related methods for creating config files are deprecated, see
[Migration](Migration#migrating-to-158)
* Support for the older versions of the [GitLab Plugin](https://wiki.jenkins-ci.org/display/JENKINS/GitLab+Plugin) is
deprecated, see [Migration](Migration#migrating-to-158)
* 1.57 (January 15 2017)
* Updated optional
[Config File Provider Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Config+File+Provider+Plugin) dependency to
@@ -169,6 +169,11 @@ The classes `javaposse.jobdsl.dsl.Config`, `javaposse.jobdsl.dsl.ConfigFile`,
`getConfigFileId` in `javaposse.jobdsl.dsl.JobManagement` and it's implementing classes are
[[deprecated|Deprecation-Policy]] and will be removed.

### GitLab

Support for versions older than 1.4.0 of the [GitLab Plugin](https://wiki.jenkins-ci.org/display/JENKINS/GitLab+Plugin)
is [[deprecated|Deprecation-Policy]] and will be removed.

## Migrating to 1.57

### Rbenv
@@ -5,11 +5,7 @@ job('example') {
buildOnPushEvents(false)
enableCiSkip(false)
setBuildDescription(false)
addNoteOnMergeRequest(false)
rebuildOpenMergeRequest('never')
addVoteOnMergeRequest(false)
useCiFeatures(false)
acceptMergeRequestOnSuccess()
includeBranches('include1,include2')
excludeBranches('exclude1,exclude2')
}
@@ -2,6 +2,7 @@ package javaposse.jobdsl.dsl.helpers.triggers

import javaposse.jobdsl.dsl.AbstractContext
import javaposse.jobdsl.dsl.JobManagement
import javaposse.jobdsl.dsl.RequiresPlugin

import static javaposse.jobdsl.dsl.Preconditions.checkArgument

@@ -21,7 +22,8 @@ class GitLabTriggerContext extends AbstractContext {
boolean addVoteOnMergeRequest = true
boolean useCiFeatures = false
boolean acceptMergeRequestOnSuccess = false
boolean allowAllBranches = false
String noteRegex = 'Jenkins please retry a build'
boolean skipWorkInProgressMergeRequest = true

GitLabTriggerContext(JobManagement jobManagement) {
super(jobManagement)
@@ -86,39 +88,35 @@ class GitLabTriggerContext extends AbstractContext {
/**
* If set, adds a note with build status on merge requests. Defaults to {@code true}.
*/
@Deprecated
void addNoteOnMergeRequest(boolean addNoteOnMergeRequest = true) {
this.addNoteOnMergeRequest = addNoteOnMergeRequest
}

/**
* If set, adds a vote to note with build status on merge requests. Defaults to {@code true}.
*/
@Deprecated
void addVoteOnMergeRequest(boolean addVoteOnMergeRequest = true) {
this.addVoteOnMergeRequest = addVoteOnMergeRequest
}

/**
* If set, enables GitLab 8.1 CI features. Defaults to {@code false}.
*/
@Deprecated
void useCiFeatures(boolean useCiFeatures = true) {
this.useCiFeatures = useCiFeatures
}

/**
* If set, accepts merge request on success. Defaults to {@code false}.
*/
@Deprecated
void acceptMergeRequestOnSuccess(boolean acceptMergeRequestOnSuccess = true) {
this.acceptMergeRequestOnSuccess = acceptMergeRequestOnSuccess
}

/**
* If set, ignores filtered branches. Defaults to {@code false}.
*/
@Deprecated
void allowAllBranches(boolean allowAllBranches = true) {
this.allowAllBranches = allowAllBranches
}

/**
* Only rebuild open Merge Requests. Defaults to {@code 'never'}.
*
@@ -131,4 +129,24 @@ class GitLabTriggerContext extends AbstractContext {
)
this.rebuildOpenMergeRequest = rebuildOpenMergeRequest
}

/**
* When filled, commenting this phrase in the merge request will trigger a build.
*
* @since 1.58
*/
@RequiresPlugin(id = 'gitlab-plugin', minimumVersion = '1.2.4')
void commentTrigger(String commentTrigger) {
this.noteRegex = commentTrigger
}

/**
* If set, ignores work in progress pull requests.
*
* @since 1.58
*/
@RequiresPlugin(id = 'gitlab-plugin', minimumVersion = '1.2.4')
void skipWorkInProgressMergeRequest(boolean skipWorkInProgressMergeRequest = true) {
this.skipWorkInProgressMergeRequest = skipWorkInProgressMergeRequest
}
}
@@ -208,6 +208,8 @@ class TriggerContext extends ItemTriggerContext {
*/
@RequiresPlugin(id = 'gitlab-plugin', minimumVersion = '1.2.0')
void gitlabPush(@DslContext(GitLabTriggerContext) Closure closure) {
jobManagement.logPluginDeprecationWarning('gitlab-plugin', '1.4.0')

GitLabTriggerContext context = new GitLabTriggerContext(jobManagement)
ContextHelper.executeInContext(closure, context)

@@ -226,6 +228,11 @@ class TriggerContext extends ItemTriggerContext {
acceptMergeRequestOnSuccess(context.acceptMergeRequestOnSuccess)
branchFilterType(context.branchFilterType)
targetBranchRegex(context.targetBranchRegex ?: '')
if (jobManagement.isMinimumPluginVersionInstalled('gitlab-plugin', '1.2.4')) {
triggerOnNoteRequest(context.noteRegex as boolean)
noteRegex(context.noteRegex ?: '')
skipWorkInProgressMergeRequest(context.skipWorkInProgressMergeRequest)
}
}
}

@@ -379,6 +379,41 @@ class TriggerContextSpec extends Specification {
acceptMergeRequestOnSuccess[0].value() == false
}
1 * mockJobManagement.requireMinimumPluginVersion('gitlab-plugin', '1.2.0')
1 * mockJobManagement.logPluginDeprecationWarning('gitlab-plugin', '1.4.0')
}

def 'call gitlabPush trigger with no options and newer plugin version'() {
setup:
mockJobManagement.isMinimumPluginVersionInstalled('gitlab-plugin', '1.2.4') >> true

when:
context.gitlabPush {
}

then:
with(context.triggerNodes[0]) {
name() == 'com.dabsquared.gitlabjenkins.GitLabPushTrigger'
children().size() == 17
spec[0].value().empty
triggerOnPush[0].value() == true
triggerOnMergeRequest[0].value() == true
triggerOpenMergeRequestOnPush[0].value() == 'never'
ciSkip[0].value() == true
setBuildDescription[0].value() == true
addNoteOnMergeRequest[0].value() == true
addCiMessage[0].value() == false
addVoteOnMergeRequest[0].value() == true
branchFilterType[0].value() == 'all'
includeBranchesSpec[0].value().empty
excludeBranchesSpec[0].value().empty
targetBranchRegex[0].value().empty
acceptMergeRequestOnSuccess[0].value() == false
triggerOnNoteRequest[0].value() == true
noteRegex[0].value() == 'Jenkins please retry a build'
skipWorkInProgressMergeRequest[0].value() == true
}
1 * mockJobManagement.requireMinimumPluginVersion('gitlab-plugin', '1.2.0')
1 * mockJobManagement.logPluginDeprecationWarning('gitlab-plugin', '1.4.0')
}

def 'call gitlabPush trigger with all options and name based filter'() {
@@ -417,6 +452,59 @@ class TriggerContextSpec extends Specification {
acceptMergeRequestOnSuccess[0].value() == value
}
1 * mockJobManagement.requireMinimumPluginVersion('gitlab-plugin', '1.2.0')
1 * mockJobManagement.logPluginDeprecationWarning('gitlab-plugin', '1.4.0')
4 * mockJobManagement.logDeprecationWarning()

where:
value << [true, false]
}

def 'call gitlabPush trigger with all options, name based filter and newer plugin version'() {
setup:
mockJobManagement.isMinimumPluginVersionInstalled('gitlab-plugin', '1.2.4') >> true

when:
context.gitlabPush {
buildOnMergeRequestEvents(value)
buildOnPushEvents(value)
enableCiSkip(value)
setBuildDescription(value)
addNoteOnMergeRequest(value)
rebuildOpenMergeRequest('both')
addVoteOnMergeRequest(value)
useCiFeatures(value)
acceptMergeRequestOnSuccess(value)
includeBranches('include1,include2')
excludeBranches('exclude1,exclude2')
commentTrigger(null)
skipWorkInProgressMergeRequest(value)
}

then:
with(context.triggerNodes[0]) {
name() == 'com.dabsquared.gitlabjenkins.GitLabPushTrigger'
children().size() == 17
spec[0].value().empty
triggerOnPush[0].value() == value
triggerOnMergeRequest[0].value() == value
triggerOpenMergeRequestOnPush[0].value() == 'both'
ciSkip[0].value() == value
setBuildDescription[0].value() == value
addNoteOnMergeRequest[0].value() == value
addCiMessage[0].value() == value
addVoteOnMergeRequest[0].value() == value
branchFilterType[0].value() == 'nameBasedFilter'
includeBranchesSpec[0].value() == 'include1,include2'
excludeBranchesSpec[0].value() == 'exclude1,exclude2'
targetBranchRegex[0].value().empty
acceptMergeRequestOnSuccess[0].value() == value
triggerOnNoteRequest[0].value() == false
noteRegex[0].value() == ''
skipWorkInProgressMergeRequest[0].value() == value
}
1 * mockJobManagement.requireMinimumPluginVersion('gitlab-plugin', '1.2.0')
1 * mockJobManagement.logPluginDeprecationWarning('gitlab-plugin', '1.4.0')
4 * mockJobManagement.logDeprecationWarning()

where:
value << [true, false]
@@ -457,6 +545,8 @@ class TriggerContextSpec extends Specification {
acceptMergeRequestOnSuccess[0].value() == value
}
1 * mockJobManagement.requireMinimumPluginVersion('gitlab-plugin', '1.2.0')
1 * mockJobManagement.logPluginDeprecationWarning('gitlab-plugin', '1.4.0')
4 * mockJobManagement.logDeprecationWarning()

where:
value << [true, false]

2 comments on commit c3d89c3

@isugimpy

This comment has been minimized.

Copy link

@isugimpy isugimpy replied Feb 17, 2017

I know this is way late, since it's already merged, but why are the addNoteOnMergeRequest and addVoteOnMergeRequest methods being deprecated? That appears to be standard functionality that isn't due to be deprecated from the GitLab plugin, and is a great way to provide feedback on triggered builds.

@daspilker

This comment has been minimized.

Copy link
Member Author

@daspilker daspilker replied Feb 18, 2017

Those options have been removed from the trigger in 1.4.0, see jenkinsci/gitlab-plugin@adc2c63 and jenkinsci/gitlab-plugin@b78c69d.

Please sign in to comment.