I wanted to run a jenkins job by accepting a date field (in format YYYY-MM-DD) from user. I found a link where user can enter a string parameter:
jo
There seems to be no plugin which provides a date chooser.
But you can use the Validating String Parameter Plugin, which can use a regular expression to validate a string parameter. See Regex to validate date format dd/mm/yyyy for regular expressions matching date values.
The Job DSL plugin has no built-in support for the Validating String Parameter Plugin, but you can use a Configure Block to add the relevant config XML.
job('example') {
configure { project ->
project / 'properties' / 'hudson.model.ParametersDefinitionProperty' / parameterDefinitions << 'hudson.plugins.validating__string__parameter.ValidatingStringParameterDefinition' {
name('DATE')
description('date in YYYY-MM-DD format')
defaultValue('2016-03-01')
regex(/\d\d\d\d-\d\d-\d\d/)
failedValidationMessage('Enter a YYYY-MM-DD date value!')
}
}
}