jenkins 无法为多分支管道作业创建pollSCM触发器

8aqjt8rx  于 2023-04-11  发布在  Jenkins
关注(0)|答案(1)|浏览(220)

我有一个MultiBranch管道作业,我想轮询我的Github来扫描任何新的提交并触发构建,所以请参阅我添加的文档

#!/usr/bin/env groovy

multibranchPipelineJob('mb-build') {
    displayName('Multi Branch Build')

    orphanedItemStrategy {
        discardOldItems {
            daysToKeep(1)
            numToKeep(1)
        }
    }

    triggers { pollSCM('H/2 * * * *') }

    factory {
        workflowBranchProjectFactory {
            scriptPath('Jenkinsfile')
        }
    }

    branchSources {
        branchSource {
            source {
                git {
                    id('some-id') 
                    remote('https://github.com/org/repo')
                    credentialsId('my-cred-here')
                }
            }
        }
    }

    configure {        
        def traitsBlock = it / sources / data / 'jenkins.branch.BranchSource' / source / traits
        traitsBlock << 'jenkins.plugins.git.traits.BranchDiscoveryTrait' {}
    }
}

但我得到的错误是

ERROR: (unknown source) No signature of method: javaposse.jobdsl.dsl.helpers.triggers.MultibranchWorkflowTriggerContext.pollSCM() is applicable for argument types: (java.lang.String) values: [H/2 * * * *]
Possible solutions: collect(), collect(groovy.lang.Closure)

版本:Jenkins 2.319.3 job-dsl 1.77

dauxcl2d

dauxcl2d1#

试试这样的方法:

triggers {
    scm('*/5 * * * *')
}

相关问题