【问题标题】:Jenkins Auto Build Trigger for 2 branches2个分支的Jenkins自动构建触发器
【发布时间】:2020-01-09 10:11:57
【问题描述】:

所以我目前正在尝试构建一个 Jenkins 管道,该管道由通过 bitbucket webhooks 提交到两个分支之一自动触发。

为了让作业开始工作,我必须手动触发为两个分支之一启动构建的作业。从这里我可以提交并推送到该分支并看到 Jenkins 作业自动被触发。

我遇到的问题是,即使在提交/推送更改时,它也永远不会构建另一个分支。

谁能帮我找出为什么只建一个分支而不建另一个? (触发的是开发分支)

String folderPath = 'folder/path'
folder("$folderPath")

pipelineJob("$folderPath/the-pipeline") {
  description 'WARNING: This pipeline is generated automatically any manual changes may be overwritten.'
  triggers {
    bitbucketPush()
  }
  definition {
    cpsScm {
        scm {
            git {
                remote {
                    url 'git@bitbucket.company/project.git'
                    credentials 'bitbucket-credentials'
                }
                branches('develop', 'master')
            }
        }
        scriptPath("Jenkinsfile")
    }
    concurrentBuild(false)
}
logRotator {
    daysToKeep(-1)
    numToKeep(15)
    artifactDaysToKeep(-1)
    artifactNumToKeep(15)
}

【问题讨论】:

  • 可能是其他分支可能没有jenkinsfile,导致问题

标签: git jenkins


【解决方案1】:

所以我不确定这是否是一个错误,我发现“分支”中的第一个分支是被触发的分支,而其他分支被忽略了。我改为使用正则表达式将“分支”更改为“分支”:^((ref[\/])?origin[\/])?(master|develop)$

查看此处了解更多信息,https://jenkins.io/doc/pipeline/steps/workflow-scm-step/。搜索:<regular expression>

【讨论】:

    猜你喜欢
    • 2020-08-24
    • 2019-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-15
    相关资源
    最近更新 更多