我正在尝试使用配置作为代码(JCasC)插件来创建一个定期构建的管道作业,但我无法在线找到这方面的语法。我正在用YAML编写配置。
“构建定期”字段位于管道作业中的Build触发器之下,并有一个名为Schedule的文本字段。我的日程是0 6-19 * * *
这能做到吗?
这是我试图编辑的yaml文件:
jobs:
- script: >
folder('test1'){
pipelineJob('test1/seedJobTest') {
description 'seedJobTest'
logRotator {
daysToKeep 10
}
definition {
cpsScm {
scm {
git {
remote {
credentials "xxx"
url 'xxx'
}
branches 'refs/head/master'
scriptPath 'Jenkinsfile'
extensions { }
}
}
}
}
configure { project ->
project / 'properties' / 'EnvInjectJobProperty' {
'on'('true')
'info' {
'propertiesContent'('BRANCH=master')
}
}
project / 'properties' / 'org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty' {}
}
}
}发布于 2019-09-24 18:48:12
如果使用JCasC配置生成/管道配置:
要定期构建,无论SCM如何更改,您都可以添加这个块:
triggers {
cron('0 6-19 * * *')
}要定期构建,只有当存在SCM更改时,才可以使用此块:
triggers {
scm('0 6-19 * * *')
}要在上下文中查看这个答案,下面是一个代码片段示例
jobs:
- script: |
job('PROJ-unit-tests') {
scm {
git(gitUrl)
}
triggers {
cron('0 6-19 * * *')
}
steps {
maven('-e clean test')
}
}从:https://github.com/jenkinsci/configuration-as-code-plugin/issues/876获取并调整代码片段
https://stackoverflow.com/questions/58066691
复制相似问题