如何配置通过轮询SubVersion触发的Jenkins管道? [英] How do I configure a Jenkins Pipeline to be triggered by polling SubVersion?

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

问题描述

一段时间以来,我们一直在使用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存储库时都运行该管道.管道配置确实具有"poll 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.

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

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