Jenkins管道轮询多个scm问题

时间:2017-02-15 14:54:15

标签: jenkins version-control jenkins-pipeline jenkins-job-dsl

我有一个Jenkins管道脚本,如果任何存储库中的“master”分支发生了变化(以后会有更多的东西),它应该从GitLab获取2个存储库(由Gitlab webhook触发)。 我的工作DSL配置:

pipelineJob('pipline') {      
      // Enable but do not use SCM polling. This needs to be enabled for
      // notifyCommit to work but we don't want to do any actual polling.
      configure { project ->
        project / 'triggers' << 'hudson.triggers.SCMTrigger' {
          spec('')
        }
      }       
        definition {
            cps {
            sandbox(true)    
            script ('''node('Foo') {
    //repo abc
     checkout changelog: false,
        poll: true,
        scm: [$class: 'GitSCM',
            branches: [[name: 'refs/heads/master']],
            doGenerateSubmoduleConfigurations: false,
            extensions: [
            [$class: 'SubmoduleOption',
            disableSubmodules: true,
            parentCredentials: false,
            recursiveSubmodules: false,
            reference: '',
            trackingSubmodules: false],
            [$class: 'RelativeTargetDirectory',
            relativeTargetDir: "abc"]
            ],
            submoduleCfg: [],
            userRemoteConfigs: [
            [url: '<repository abc>'],
            [refspec: '+refs/heads/master:refs/remotes/origin/master'],
            [name: 'origin']
            ]]      
    //repo def
      checkout changelog: false,
        poll: true,
        scm: [$class: 'GitSCM',
            branches: [[name: 'refs/heads/master']],
            doGenerateSubmoduleConfigurations: false,
            extensions: [
            [$class: 'CheckoutOption', timeout: 20],
            [$class: 'SubmoduleOption',
            disableSubmodules: true,
            parentCredentials: false,
            recursiveSubmodules: false,
            reference: '',
            trackingSubmodules: false],
            [$class: 'RelativeTargetDirectory',
            relativeTargetDir: "def"],
            [$class: 'PruneStaleBranch']],
            submoduleCfg: [],
            userRemoteConfigs: [
            [url: '<repository def>'],
            [refspec: '+refs/heads/master:refs/remotes/origin/master'],
            [name: 'origin']
            ]] 
         ...
         do more things
    ''')
       }
      }
    }

第一个存储库的轮询工作正常,但是当我在一个秒存储库中进行了更改而不是在主分支中时,我仍然可以完成所有操作。看起来它仅从第一个存储库获取最后一个构建版本SHA,然后使用它在所有其他存储库中进行比较。 这是git轮询日志的样子:

Started on Feb 15, 2017 12:10:09 PM
Using strategy: Default
[poll] Last Built Revision: Revision <SHA from last commit in repository abc on master branch > (refs/remotes/origin1/master)
 > git ls-remote -h <repository abc> # timeout=10
Found 4 remote heads on <repository abc>
[poll] Latest remote head revision on refs/heads/master is: <SHA from last commit in repository abc on master branch > - already built by 76
Using strategy: Default
[poll] Last Built Revision: Revision <SHA from last commit in repository abc on master branch > (refs/remotes/origin1/master)
 > git ls-remote -h <repository def> # timeout=10
Found 2 remote heads on <repository def>
[poll] Latest remote head revision on refs/heads/master is: <SHA from last commit in repository def on master branch >
Done. Took 1.1 sec
Changes found

之前我使用的是buildFlowJob,它具有相同的功能,并且运行正常。

0 个答案:

没有答案