Skip to content

Commit

Permalink
Merge pull request #1250 from jsmrcka/JENKINS-68781
Browse files Browse the repository at this point in the history
Add missing options for Parameterized Remote Trigger Plugin
  • Loading branch information
jamietanna committed Jul 18, 2022
2 parents d47672c + b01d987 commit 2fb0050
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/Home.md
Expand Up @@ -32,6 +32,8 @@ scripts, including [[tests for DSL scripts|Testing DSL Scripts]] and [[IDE Suppo
Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins-ci.org/issues/?filter=15140).

## Release Notes
* 1.81.0 (July 18 2022)
* Add missing options for Parameterized Remote Trigger Plugin ([GH-1250](https://github.com/jenkinsci/job-dsl-plugin/pull/1250) [JENKINS-68781](https://issues.jenkins.io/browse/JENKINS-68781)).
* 1.80.0 (July 1 2022)
* Don't destroy credentials when re-creating organization folders ([GH-1251](https://github.com/jenkinsci/job-dsl-plugin/pull/1251) [JENKINS-44681](https://issues.jenkins.io/browse/JENKINS-44681))
* 1.79.0 (April 14 2022)
Expand Down
Expand Up @@ -11,6 +11,16 @@ class ParameterizedRemoteTriggerContext extends AbstractContext {
boolean blockBuildUntilComplete = false
String token
String credentialsIds
String remoteJenkinsUrl
boolean abortTriggeredJob = false
int maxConn = 1
boolean enhancedLogging = false
boolean useCrumbCache = true
boolean useJobInfoCache = true
boolean disabled = false
boolean overrideTrustAllCertificates = false
boolean trustAllCertificates = false
String parameterFile

ParameterizedRemoteTriggerContext(JobManagement jobManagement) {
super(jobManagement)
Expand Down Expand Up @@ -85,4 +95,114 @@ class ParameterizedRemoteTriggerContext extends AbstractContext {
void overrideCredentials(String credentialsIds) {
this.credentialsIds = credentialsIds
}

/**
* If set, overrides the Remote Jenkins URL for this Job alone.
*
* @since 1.81
*/
void remoteJenkinsUrl(String remoteJenkinsUrl) {
this.remoteJenkinsUrl = remoteJenkinsUrl
}

/**
* Abort remote job if current job was aborted. Defaults to {@code false}.
*
* @since 1.81
*/
void abortTriggeredJob(boolean abortTriggeredJob = true) {
this.abortTriggeredJob = abortTriggeredJob
}

/**
* Set the max concurrent connections to the remote host, default is 1, max is 5.
* It'll be 5 even if you set it greater than 5.
*
* Note: Set this field with caution, too many concurrent requests will not only fail your local jobs,
* but also block the remote server.
*
* @since 1.81
*/
void maxConn(int maxConn) {
this.maxConn = maxConn
}

/**
* If set, the console output of the remote job is also logged. Defaults to {@code false}.
*
* @since 1.81
*/
void enhancedLogging(boolean enhancedLogging = true) {
this.enhancedLogging = enhancedLogging
}

/**
* Enable cache of the crumb of remote server. Defaults to {@code true}.
*
* It'll be more efficient for the local job execution & more stable for remote server when massive concurrent
* jobs are triggered.
* This cache will be cleared every 10 minutes.
*
* @since 1.81
*/
void useCrumbCache(boolean useCrumbCache = true) {
this.useCrumbCache = useCrumbCache
}

/**
* Enable cache of the job info of remote server. Defaults to {@code true}.
*
* It'll be more efficient for the local job execution & more stable for remote server when massive concurrent
* jobs are triggered.
* This cache will be cleared every 10 minutes.
*
* @since 1.81
*/
void useJobInfoCache(boolean useJobInfoCache = true) {
this.useJobInfoCache = useJobInfoCache
}

/**
* Disable the job step instead of removing it from job configuration. Defaults to {@code false}.
*
* @since 1.81
*/
void disabled(boolean disabled = true) {
this.disabled = disabled
}

/**
* Specify, whether the {@link #trustAllCertificates()} option will be taken into account.
* Defaults to {@code false}.
*
* @since 1.81
*/
void overrideTrustAllCertificates(boolean overrideTrustAllCertificates = true) {
this.overrideTrustAllCertificates = overrideTrustAllCertificates
}

/**
* Override/rewrite the 'Trust all certificate'-setting for this Job alone. Defaults to {@code false}.
*
* Setting this checkbox to {@code true} will result in accepting all certificates for the given Job.
* If the remote Jenkins host has a self-signed certificate or its certificate is not trusted,
* you may want to enable this option. It will accept untrusted certificates for the given host.
*
* This is unsafe and should only be used for testing or if you trust the host.
*
* @since 1.81
*/
void trustAllCertificates(boolean trustAllCertificates = true) {
this.trustAllCertificates = trustAllCertificates
}

/**
* Specify parameter path + name of an external file, which parameters should be loaded from.
* All paths are relative to the current workspace.
*
* @since 1.81
*/
void parameterFile(String parameterFile) {
this.parameterFile = parameterFile
}
}
Expand Up @@ -622,8 +622,19 @@ class StepContext extends AbstractExtensibleContext {
CREDENTIALS__PLUGIN('credentialsPlugin')
}
}
loadParamsFromFile(false)
parameterFile()
loadParamsFromFile(context.parameterFile as boolean)
parameterFile(context.parameterFile)
if (context.remoteJenkinsUrl) {
remoteJenkinsUrl(context.remoteJenkinsUrl)
}
abortTriggeredJob(context.abortTriggeredJob)
maxConn(context.maxConn)
enhancedLogging(context.enhancedLogging)
useCrumbCache(context.useCrumbCache)
useJobInfoCache(context.useJobInfoCache)
disabled(context.disabled)
overrideTrustAllCertificates(context.overrideTrustAllCertificates)
trustAllCertificates(context.trustAllCertificates)
queryString()
}
}
Expand Down
Expand Up @@ -2385,7 +2385,7 @@ class StepContextSpec extends Specification {
context.stepNodes.size() == 1
with(context.stepNodes[0]) {
name() == 'org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration'
children().size() == 14
children().size() == 22
token[0].value() == ''
remoteJenkinsName[0].value() == 'dev-ci'
job[0].value() == 'test'
Expand All @@ -2405,7 +2405,15 @@ class StepContextSpec extends Specification {
CREDENTIALS__PLUGIN[0].value() == 'credentialsPlugin'
}
loadParamsFromFile[0].value() == false
parameterFile[0].value() == []
parameterFile[0].value() == null
abortTriggeredJob[0].value() == false
maxConn[0].value() == 1
enhancedLogging[0].value() == false
useCrumbCache[0].value() == true
useJobInfoCache[0].value() == true
disabled[0].value() == false
overrideTrustAllCertificates[0].value() == false
trustAllCertificates[0].value() == false
queryString[0].value() == []
}
1 * jobManagement.requireMinimumPluginVersion('Parameterized-Remote-Trigger', '2.0')
Expand All @@ -2423,7 +2431,7 @@ class StepContextSpec extends Specification {
context.stepNodes.size() == 1
with(context.stepNodes[0]) {
name() == 'org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration'
children().size() == 14
children().size() == 22
token[0].value() == ''
remoteJenkinsName[0].value() == 'dev-ci'
job[0].value() == 'test'
Expand All @@ -2447,7 +2455,15 @@ class StepContextSpec extends Specification {
CREDENTIALS__PLUGIN[0].value() == 'credentialsPlugin'
}
loadParamsFromFile[0].value() == false
parameterFile[0].value() == []
parameterFile[0].value() == null
abortTriggeredJob[0].value() == false
maxConn[0].value() == 1
enhancedLogging[0].value() == false
useCrumbCache[0].value() == true
useJobInfoCache[0].value() == true
disabled[0].value() == false
overrideTrustAllCertificates[0].value() == false
trustAllCertificates[0].value() == false
queryString[0].value() == []
}
1 * jobManagement.requireMinimumPluginVersion('Parameterized-Remote-Trigger', '2.0')
Expand All @@ -2469,7 +2485,7 @@ class StepContextSpec extends Specification {
context.stepNodes.size() == 1
with(context.stepNodes[0]) {
name() == 'org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration'
children().size() == 14
children().size() == 22
token[0].value() == 'test'
remoteJenkinsName[0].value() == 'dev-ci'
job[0].value() == 'test'
Expand All @@ -2491,7 +2507,15 @@ class StepContextSpec extends Specification {
CREDENTIALS__PLUGIN[0].value() == 'credentialsPlugin'
}
loadParamsFromFile[0].value() == false
parameterFile[0].value() == []
parameterFile[0].value() == null
abortTriggeredJob[0].value() == false
maxConn[0].value() == 1
enhancedLogging[0].value() == false
useCrumbCache[0].value() == true
useJobInfoCache[0].value() == true
disabled[0].value() == false
overrideTrustAllCertificates[0].value() == false
trustAllCertificates[0].value() == false
queryString[0].value() == []
}
1 * jobManagement.requireMinimumPluginVersion('Parameterized-Remote-Trigger', '2.0')
Expand Down

0 comments on commit 2fb0050

Please sign in to comment.