Dan*_*ano 25 jenkins jenkins-pipeline multibranch-pipeline
我开始创建我的管道multibranch环境,但我已经找到了一个问题.
我是否可以仅使用Jenkins文件检测分支但没有管道执行的情况下运行构建扫描?
我的项目有不同的分支,我不想要当我从父管道multibranch启动构建扫描所有子管道foreach分支与Jenkinsfile开始执行.
谢谢你的帮助!
小智 25
在" 分支源"部分中,您可以添加名为"抑制自动SCM触发"的属性.
这可以防止Jenkins使用Jenkinsfile构建所有内容.
此外,您可以以编程方式进行
import jenkins.branch.*
import jenkins.model.Jenkins
for (f in Jenkins.instance.getAllItems(jenkins.branch.MultiBranchProject.class)) {
if (f.parent instanceof jenkins.branch.OrganizationFolder) {
continue;
}
for (s in f.sources) {
def prop = new jenkins.branch.NoTriggerBranchProperty();
def propList = [prop] as jenkins.branch.BranchProperty[];
def strategy = new jenkins.branch.DefaultBranchPropertyStrategy(propList);
s.setStrategy(strategy);
}
f.computation.run()
}
Run Code Online (Sandbox Code Playgroud)
这是一个您可以在 Jenkins 中执行的 Groovy 片段,它会进行扫描,但不会为所有发现的分支启动新的“构建”。
如果您使用的是 job-dsl,您可以简单地执行此操作,它会扫描所有内容,而无需在第一次索引时实际运行构建。
organizationFolder('Some folder name') {
buildStrategies {
skipInitialBuildOnFirstBranchIndexing()
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8681 次 |
| 最近记录: |