class DslUtil {
static configureTfsParams(jobContext) {
configureValidatingParam(jobContext, [
name:'TFS_SERVER_URL',
description:'Example Desc A',
regex:'.+',
failedValidationMessage:'Give me A'
])
configureValidatingParam(jobContext, [
name:'EXAMPLE_PROJECT_PATH',
description:'Example Desc B',
regex:'.+',
failedValidationMessage:'Give me B'
])
}
static configureValidatingParam(jobContext, params) {
jobContext.with {
configure {
it / 'properties' / 'hudson.model.ParametersDefinitionProperty' / 'parameterDefinitions' << 'hudson.plugins.validating__string__parameter.ValidatingStringParameterDefinition' {
'description'(params.description)
'defaultValue'(params.defaultValue)
'regex'(params.regex)
'failedValidationMessage'(params.failedValidationMessage)
}
}
}
}
}
job('test') {
DslUtil.configureTfsParams delegate
DslUtil.configureValidatingParam(delegate, [
name:'APP_NAME',
description:'Name of the application to deploy',
regex:'.+',
failedValidationMessage:'Must supply an application to deploy'
])
DslUtil.configureValidatingParam(delegate, [
name:'APP_VERSION',
description:'Version of the application to deploy',
regex:'.+',
failedValidationMessage:'Must supply a version to deploy'
])
DslUtil.configureValidatingParam(delegate, [
name:'TARGET_VM',
description:'Server that should have application after deploy',
regex:'.+',
failedValidationMessage:'Must supply a server to deploy'
])