Kaba
Kaba

Reputation: 83

Jenkins pipeline into a schedule

I was wondering whats the best approach to Schedule a Jenkins pipeline to run every n amount of time or at a specific time of day.

Right now I am running it with a Choice Parameter that can be a value from 0 to 7. Inside of my groovy script, it is also calling a shell script and passing a the Choice Parameter as parameter.

So, this are the two solutions I was thinking but I dont know how to do any of them.

  1. This is my dreamed approach for sure. Use a mac crone schedule to somehow call the pipeline in my Jenkins local server. I was wondering if there is a way to call the pipeline or the groovy script inside of it and pass the parameter, like a web API for example. Something like: localhost/pipeline?=4 (4 would be the value I am passing). And make it run at certain moments of the day. Different value parameter at different time of day.

  2. Somehow generate a value from 0 to 7 inside my pipeline groovy script and use that value to run the shell script and call it through a Jenkins Job.

Or do you guys have any other suggestion to accomplish this?

Here is some context that may be not relevant:

My groovy script is "adb connecting" to an android device plugged to the jenkins server and running a shell script in my master branch, this script expects a value from 0 to 7. I need to run the script providing as parameter the 8 possible values (0,1...7) in the same day.

Upvotes: 0

Views: 646

Answers (1)

towel
towel

Reputation: 2214

You can use a cron-like syntax to schedule a pipeline build at any time you'd like to. For example H 0 * * * builds once a day between midnight and 1 am:

Pipeline build triggers

Upvotes: 2

Related Questions