如何配置 Jenkins 流水线以通过轮询 SubVersion 来触发? [英] How do I configure a Jenkins Pipeline to be triggered by polling SubVersion?

查看:68
本文介绍了如何配置 Jenkins 流水线以通过轮询 SubVersion 来触发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我们一直在使用 Jenkins 进行持续集成.典型的构建作业在源代码管理"部分指定 SVN 存储库和凭据,然后在构建触发器"部分中,我们启用轮询 SCM",轮询计划为每 10 分钟 (H/10 * * * *).我们已更新到最新版本的 Jenkins,并正在寻求建立管道构建.典型的管道脚本如下所示:

We have been using Jenkins for Continuous Integration for some time. A typical build job specifies the SVN repository and credentials in the "Source Code Management" section, then in the "Build Triggers" section we enable "Poll SCM" with a polling schedule of every 10 minutes (H/10 * * * *). We have updated to the latest version of Jenkins and are looking to set up pipeline builds. A typical pipeline script looks like:

node {
    stage 'Build'
    build job: 'MyApplication Build'
    stage 'Deploy to test environment'
    build job: 'MyApplication Deploy', parameters: [
        [$class: 'StringParameterValue', name: 'DatabaseServer', value: 'DatabaseServer1'],
        [$class: 'StringParameterValue', name: 'WebServer', value: 'WebServer1']
    ]
    stage 'RunIntegrationTests'
    build job: 'MyApplication Test', parameters: [
        [$class: 'StringParameterValue', name: 'DatabaseServer', value: 'DatabaseServer1'],
        [$class: 'StringParameterValue', name: 'WebServer', value: 'WebServer1']
    ]
}

当手动触发管道作业时,一切运行正常,但是我们希望每次将新修订签入到 SVN 存储库时都运行此管道.管道配置确实有一个轮询 SCM"构建触发器选项,但没有一个源代码管理"部分,您可以在其中指定您的存储库.我们怎样才能做到这一点?

When the pipeline job is triggered manually then everything runs fine, however we would like this pipeline to be run every time a new revision is checked in to the SVN repository. The pipeline configuration does have a "poll SCM" build trigger option, but does not have a "Source Code Management" section where you can specify your repository. How can we achieve this?

推荐答案

我发现可行的解决方案是:

The solution that I have found to work is:

  1. 将管道脚本移动到一个文件中(默认为 JenkinsFile),并将其存储在我的项目根目录中的 SubVersion 中.
  2. 将我的管道作业定义源设置为来自 SCM 的管道脚本",按照正常的 Jenkins 构建作业输入在 SubVersion 中找到我的项目的详细信息,并将脚本路径设置为指向包含管道脚本的 JenkinsFile.
  3. 将管道作业的构建触发器设置为轮询 SCM"并输入计划.
  4. 手动运行管道作业

这似乎是第 4 步,手动运行导致轮询触发器选择正确的存储库进行轮询的管道作业.在此之前,它似乎不知道去哪里找.

It seemed to be step 4, manually running the pipeline job that caused the poll trigger to pick up the correct repository to poll. Before that it didn't seem to know where to look.

这篇关于如何配置 Jenkins 流水线以通过轮询 SubVersion 来触发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆