轮询 SCM:Jenkins 管道脚本未在 SVN 提交时唤醒

Polling SCM: Jenkins Pipeline Script not waking up on SVN Commit

我是 Jenkins Pipeline Script 的新手,我已将我的 FreeStyle 项目移动到一个 Pipeline,但是当我提交到我的 SVN 存储库时,我无法唤醒我的主服务器。这是我的前几行以及声明我的 SVN 凭据的位置:

node {
try {
    notifyBuild('STARTED')

stage('Checkout') {
checkout([$class: 'SubversionSCM',
    additionalCredentials: [], 
    excludedCommitMessages: '', 
    excludedRegions: '', 
    excludedRevprop: '', 
    excludedUsers: 'buildbot', 
    filterChangelog: false, 
    ignoreDirPropChanges: false, 
    includedRegions: '', 
    locations: [[credentialsId: 'my-login-id-creds-are-here', 
        depthOption: 'infinity', 
        ignoreExternalsOption: true, 
        local: '.', 
        remote: "http://this.is.myweburl.com/svn/path/to/branch"]],
    workspaceUpdater: [$class: 'UpdateUpdater']])
}

有没有办法轮询 SCM?

如果您有任何问题,请告诉我。

谢谢!

这是一个简短的清单:

  • 在您的管道作业中,在 "Build Triggers" 下,配置 "Poll SCM"(例如 H/2 * * * * 每 2 分钟轮询一次)
  • 如果您最近编辑了管道脚本并更改了其中的 SVN 配置(例如,将分支更改为轮询),您可能需要单击 "Build Now" 一次以更新 SVN 轮询配置。
  • 检查您的 SCM 过滤器(包括*/排除*)。在提供的示例中,我看到您通过 'buildbot' 过滤掉提交,确保不是这种情况。
  • 时区和时间同步问题:确保在 SVN 和 Jenkins 主服务器上都正确配置了正确的时区和 date/time。将“@HEAD”附加到 SVN URL 可能会避免一些时间同步问题(例如 http://this.is.myweburl.com/svn/path/to/branch@HEAD)。
  • 检查作业页面中的 "Subversion Polling Log",可能有助于解决 network/credential 问题。

您是否尝试在 Jenkinsfile 中添加 properties 以触发时间?

properties([
   pipelineTriggers([cron('H/30 * * * *')])
])

在脚本和 declarative pipeline 中有不同的方法来执行此操作,并且两者都会在第一次执行后将相关参数创建到您的 jenkins 作业中。

我看到了这个确切的问题,即使在遵循此处的答案之后也是如此。对我来说,Jenkins 没有进行轮询的原因是大约 10 个构建之前,我有一个没有 scm 检出步骤的构建通过了,但是所有后续构建(确实有 scm 检出步骤)都失败了。

我认为 Jenkins 忽略了这些,可能是由于 this WorkflowJob code