How do I run a Jenkins job where user can enter a date value?

后端 未结 1 1609
有刺的猬
有刺的猬 2021-01-23 04:51

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         


        
相关标签:
1条回答
  • 2021-01-23 05:29

    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!')
        }
      }
    }
    
    0 讨论(0)
提交回复
热议问题