如何正确使用Jenkins管道`options` [英] How to use Jenkins pipeline `options` correctly
本文介绍了如何正确使用Jenkins管道`options`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
摘要生成器为我创建了一个properties
块.首次运行报告
Snippet generator created a properties
block for me. First run reported
WorkflowScript: 1: The properties section has been renamed as of version 0.8. Use options instead. @ line 1, column 1.
pipeline {
将properties
替换为options
会导致以下错误:
Replacing properties
to options
results with the following error:
Errors encountered validating Jenkinsfile:
WorkflowScript: 4: options can not be empty @ line 4, column 5.
options([$class: 'ThrottleJobProperty',
完整的jenkinsfile
供参考
pipeline {
agent any
options([[$class: 'ThrottleJobProperty',
categories: ['xcodebuild'],
limitOneJobWithMatchingParams: false,
maxConcurrentPerNode: 0,
maxConcurrentTotal: 0,
paramsToUseForLimit: '',
throttleEnabled: true,
throttleOption: 'category']])
stages {
stage("Empty" {
steps {
echo "Do nothing"
}
}
}
}
推荐答案
TLDR
在选项中不再可以使用自定义$class
请注意,不能使用
[$class: 'Foo', arg1: 'something', ...]
语法,只能使用booleanParam(...)
等.
完整选项语法
- 说明:传统的
JobProperty
(例如buildDiscarder
或disableConcurrentBuilds
),声明性的特定选项(例如skipDefaultCheckout
)和包装器"(应该包装整个构建,例如timeout
. - 必需:否
- 允许:仅顶级
pipeline
关闭. - 参数:无
- 闭幕:是
- 关闭内容:一个或多个声明性选项或作业属性配置的序列,使用
@Symbol
名称作为构造函数.- 请注意,不能使用
[$class: 'Foo', arg1: 'something', ...]
语法,只能使用booleanParam(...)
等. - 请注意,不能在此处直接使用
parameters
和pipelineTriggers
@Symbol
. - Description: Traditional
JobProperty
s, such asbuildDiscarder
ordisableConcurrentBuilds
, Declarative-specifc options, such asskipDefaultCheckout
, and "wrappers" that should wrap the entire build, such astimeout
. - Required: No
- Allowed In: Top-level
pipeline
closure only. - Parameters: None
- Takes a Closure: Yes
- Closure Contents: A sequence of one or more Declarative option or job property configurations, using
@Symbol
names for constructors.- Note that
[$class: 'Foo', arg1: 'something', ...]
syntax can not be used, onlybooleanParam(...)
and the like. - Note that the
parameters
andpipelineTriggers
@Symbol
s cannot be used here directly.
示例:
options { buildDiscarder(logRotator(numToKeepStr:'1')) disableConcurrentBuilds() }
这篇关于如何正确使用Jenkins管道`options`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Note that
Full Options Syntax
- 请注意,不能使用
查看全文