jenkins yaml Jcasc 触发器和轮询 scm 自动添加作业
jenkins yaml Jcasc triggers and poll scm to add jobs automatically
我有以下 jenkins yaml,它可以自动运行并放入作业。它不会添加凭据,除非我进入 UI 和 select 相同的 ID "github" 或允许我添加轮询或触发
我尝试了多种组合,要么导致部署崩溃,要么根本不添加作业。
triggers {
pollSCM 'H/10 * * * *'
}
triggers {
cron (H/10 * * * *)
}
我想添加 cron 和 poll scm,因为作业是 运行 手动从 repo jenkinsfile
中提取的
jenkins:
systemMessage: "Jenkins: configured automatically with JCasC plugin\n\n"
tool:
git:
installations:
- home: "git"
name: "Default"
jobs:
- script: >
pipelineJob('my_pipleline_build') {
definition {
cpsScm {
scriptPath 'Jenkinsfile'
scm {
git {
remote { url 'https://github.com/my_pipleline_build.git' }
branch '*/master'
credentials: ('github')
extensions {}
}
}
}
}
}
- script: >
pipelineJob('my_other_pipleline_build') {
definition {
cpsScm {
scriptPath 'Jenkinsfile'
scm {
git {
remote { url 'https://github.com/cloud/my_other_pipleline_build.git' }
branch '*/my_pipleline_build'
credentials: ('github')
extensions {}
}
}
}
}
}
我用下面的方法实现了,
- script: >
pipelineJob('my_other_pipleline_build') {
definition {
cpsScm {
scriptPath 'Jenkinsfile'
scm {
git {
remote { url 'https://github.com/cloud/my_other_pipleline_build.git'
credentials('github')
}
branch '*/my_pipleline_build'
extensions {}
}
triggers {
cron("H 12 * * 6")
}
}
}
}
}
我有以下 jenkins yaml,它可以自动运行并放入作业。它不会添加凭据,除非我进入 UI 和 select 相同的 ID "github" 或允许我添加轮询或触发
我尝试了多种组合,要么导致部署崩溃,要么根本不添加作业。
triggers {
pollSCM 'H/10 * * * *'
}
triggers {
cron (H/10 * * * *)
}
我想添加 cron 和 poll scm,因为作业是 运行 手动从 repo jenkinsfile
中提取的jenkins:
systemMessage: "Jenkins: configured automatically with JCasC plugin\n\n"
tool:
git:
installations:
- home: "git"
name: "Default"
jobs:
- script: >
pipelineJob('my_pipleline_build') {
definition {
cpsScm {
scriptPath 'Jenkinsfile'
scm {
git {
remote { url 'https://github.com/my_pipleline_build.git' }
branch '*/master'
credentials: ('github')
extensions {}
}
}
}
}
}
- script: >
pipelineJob('my_other_pipleline_build') {
definition {
cpsScm {
scriptPath 'Jenkinsfile'
scm {
git {
remote { url 'https://github.com/cloud/my_other_pipleline_build.git' }
branch '*/my_pipleline_build'
credentials: ('github')
extensions {}
}
}
}
}
}
我用下面的方法实现了,
- script: >
pipelineJob('my_other_pipleline_build') {
definition {
cpsScm {
scriptPath 'Jenkinsfile'
scm {
git {
remote { url 'https://github.com/cloud/my_other_pipleline_build.git'
credentials('github')
}
branch '*/my_pipleline_build'
extensions {}
}
triggers {
cron("H 12 * * 6")
}
}
}
}
}