有没有一种方法可以在詹金斯中指定一组参数预设值

时间:2019-10-29 17:23:57

标签: jenkins groovy parameters

是否有一种方法可以在Jenkins中指定一组预设的构建参数,因此能够为dev / test / ppe / prod设置配置文件非常好,例如具有针对这些配置文件预定义的通用值,但我找不到有关执行此操作的任何信息,这样我就可以在jenkins Web界面上选择重置配置文件并启动构建,而不必每次都重新输入值。

即使记住先前构建中使用的最后一组参数值也会很有帮助。

我只能使用声明性管道

下面是我的参数存储区,其中有几处内容经过修改,以示例说明如何在Jenkinsfile中设置参数

properties([
  parameters([
    [
      $class: 'ParameterSeparatorDefinition',
      name: 'JobVariables',
      sectionHeader: 'Deployment Settings',
      separatorStyle: separatorBlank,
      sectionHeaderStyle: sectionHeaderStyle
    ],
    choice(name: 'Job Mode', defaultValue: params['Job Mode'] ?: 'Validate', choices: ['Sceptre Single Stack', 'Deploy All', 'Deploy Common', 'Deploy SubZone', 'Teardown', 'Delete S3 Bucket'], description: 'Sceptre Deployment Mode.'),
    choice(name: 'Sceptre Mode', defaultValue: params['Sceptre Mode'] ?: 'Validate', choices: ['Validate', 'Generate', 'Create', 'Launch', 'Execute', 'Delete'], description: 'Sceptre Deployment Mode.'),
    [
      $class: 'ParameterSeparatorDefinition',
      name: 'CommonVariables',
      sectionHeader: 'Common Stack Variables',
      separatorStyle: separatorBlank,
      sectionHeaderStyle: sectionHeaderStyle
    ],
    choice(name: 'Sceptre Stack', defaultValue: params['Sceptre Stack'] ?: 'cortex-common-s3-bucket', choices: [
      'common-live-alb-route53',
      'common-s3-bucket',
      'common-s3-permissions',
      'ec2-alb-route53',
      'ec2-alb-targetgroups',
      'ec2-alb',
      'ec2-instances-route53',
      'ec2-instances',
      'ec2-securitygroups'
    ], description: 'Sceptre Stack.'),
    choice(name: 'Deploy Environment', defaultValue: params['Deploy Environment'] ?: 'Dev', choices: ['Dev','Test','PPE','Prod'], description: 'Deployment environment.'),
    [
      $class: 'ParameterSeparatorDefinition',
      name: 'EnvironmentVariables',
      sectionHeader: 'Environment Specific Variables',
      separatorStyle: separatorBlank,
      sectionHeaderStyle: sectionHeaderStyle
    ],
    choice(name: 'Deploy Zone', defaultValue: params['Deploy Zone'] ?: '', choices: ['', 'SIT1','SIT4','SIT6','Sandbox','TPP'], description: 'Deployment environment SubZone.'),
    choice(name: 'Deploy SubZone', defaultValue: params['Deploy SubZone'] ?: '', choices: ['', 'Blue','Green'], description: 'Deployment environment SubZone.'),
    string(name: 'Change Number', defaultValue: params['Change Number'] ?: '', description: 'ServiceNow Change Number.'),
    booleanParam(name: 'Debug Mode', defaultValue: params['Debug Mode'] ?: true, description: 'Activate Debug Mode'),
    booleanParam(name: 'User Prompt Default', defaultValue: params['User Prompt Default'] ?: true, description: 'Default Action on Prompt Timeout'),
  ])
])

每次都会将其重置为默认值,从理论上讲,它应至少保留我所阅读内容的先前版本

0 个答案:

没有答案