Jenkinsfile中的pollSCM和cron构建触发器

我想在Jenkinsfile中同时包含pollSCM和cron构建触发器。触发器因分支而异。

我尝试添加简单的if / elif / else条件,但是它不起作用。

下面您可以看到管道的代码。


def INITIAL_RUN = false
def SYS_ENV = 'sbx'
def TRIGGERS = []

node{

  if ( params.prepare == null ){
    print "Initial run,dont do anything,just set up the jobs parameters."
    INITIAL_RUN = true


  if (BRANCH_NAME == "development"){
    TRIGGERS = "cron('H 10 * * *')"
  } 
  else if (BRANCH_NAME == "qas"){
    TRIGGERS = "cron('H 8 * * *')"
  } 
  else if (BRANCH_NAME == "master"){
    TRIGGERS = "cron('H 6 * * *')"
  }
  else {

  }

    properties([
      parameters([
        booleanParam(name: 'prepare',defaultvalue: true,description: ''),]),pipelineTriggers([
        pollSCM('H/15 * * * *'),TRIGGERS
      ])
    ])

    print "Initialization completed."
  }

对于分支==开发,我希望这项工作每天在10点运行,并且每次有人提交更改。

您有什么想法吗?

falcomadol 回答:Jenkinsfile中的pollSCM和cron构建触发器

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3168420.html

大家都在问