Search code examples
jenkinstriggerscronjenkins-pipeline

Jenkins pipelines is multiple parametrized cron build possible?


I have a working Jenkins scripted pipeline, very simple. I am also using triggers to enable pipeline to run on a schedule.

Something like this:

node{
    do_something()
    triggers{
        cron(‘* * * * *’)
    }
}

do_something() does various things, and takes into account some input params (and env variables)

I want to trigger pipeline multiple times - lets say once a minute with some parameters, and every hour with other parameters.
(Imagine that I would like the same pipeline to be reused for continuous and full builds)

Is it possible?
I did not found a way how to do this, I am not even sure that it can be triggered by more than one trigger.


Solution

  • The trigger will trigger the entire job. It doesn't trigger parts of a job, or trigger with different parameters. What you probably want to do is setup a trigger job. Just have a simple pipeline job that triggers every minute, 10 minutes, whatever you need. That job will use logic in groovy to decide what needs to be done at that time and then trigger another job or jobs with the parameters you need.