简体   繁体   English

多分支管道 cron 上的 Jenkinsfile

[英]Jenkinsfile on multibranch pipeline cron

I have a declarative pipeline for multibranch pipeline job, and I am interested in creating a cron trigger to it.我有一个用于多分支管道作业的声明性管道,我有兴趣为它创建一个 cron 触发器。 Currently I already have cron trigger on it for master branch using the following cron string:目前,我已经使用以下 cron 字符串在其上为 master 分支设置了 cron 触发器:

String cron_string = BRANCH_NAME == "master" ? '30 23 * * *' : ""

I am interested in modifying the cron string so the cron would be triggered when branch name is master or if branch name contains the string release我有兴趣修改 cron 字符串,以便在分支名称为master或分支名称包含字符串release时触发 cron

I Wondered how can I achieve this would appreciate your help.我想知道如何才能做到这一点,感谢您的帮助。 Thanks in advance, Alon在此先感谢, 阿隆

def no_cron = ""
def some_cron = "30 23 * * *" 

CRON_DATA = no_cron

if (BRANCH_NAME == "master" || BRANCH_NAME.contains("release")) {
    CRON_DATA = some_cron 
}

pipeline {
    agent any 

    triggers {
        cron (CRON_DATA)
    }
    ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM