首页 > 解决方案 > Jenkins 管道声明性语法配置 checkout scm(特定于路径的构建触发器)

问题描述

我正在使用 Jenkins 管道(声明性语法),并希望将管道配置为使用 scm 触发器,因此只有在部分 git repo 发生更改时才会运行构建。

我查看了(管道插件)[ https://support.cloudbees.com/hc/en-us/articles/226122247-How-to-Customize-Checkout-for-Pipeline-Multibranch-]文档,示例似乎用于脚本文件语法。下面的评论说它也适用于 dsl,但找不到合适的示例用法。

查看管道日志,我看到了一个获取提交的自动步骤。

[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout

那么这是自动完成的吗?

我尝试了以下步骤,这似乎同步了代码。

stage("Checkout ") {
    steps {
        checkout(scm)
    }
}

但不知道如何使它适用于我的用例,即确保管道仅在源存储库中的特定路径发生更改时运行,例如这里的includeRegion https://jenkins.io/doc/pipeline/steps/workflow-scm -步/

标签: jenkinsjenkins-pipeline

解决方案


推荐阅读