snippetMinor
How to schedule a Jenkins Job dynamically based on the time value in database
Viewed 0 times
thedynamicallyjenkinstimevaluedatabasebasedhowschedulejob
Problem
I have a situation where there is a database in which a table consists of scheduled time to build. This schedule time to build may vary from day to day. Say for example,
So, based on the above table, I need to schedule a Jenkins job today at 5:00 PM and tomorrow at 4:00 PM Is there any possibility in Jenkins to configure the build based on the above table entries.
Thanks in advance
Today the entry in db is 09/01/2020 5:00 PM
Tomorrow the entry can be 10/01/2020 4:00 PMSo, based on the above table, I need to schedule a Jenkins job today at 5:00 PM and tomorrow at 4:00 PM Is there any possibility in Jenkins to configure the build based on the above table entries.
Thanks in advance
Solution
Jenkins itself isn't very good at using external data sources to drive dynamic job scheduling. The reason for this is that job configuration, including scheduling, is built statically, either manually via the web UI, or with code via a Pipeline script which is run at job execution time. Even if the Pipeline script builds the job configuration in a dynamic way, the configuration itself will be locked in until the next job execution.
The easiest way to have flexible build schedules is use an external source to drive your builds. The hook mentioned in the comments would be ideal, but it sounds like that is not possible for you. Another idea would be to have a cron job on your database server that runs once a day, grabs the build time from the database, and schedules the build for that time. I'm sure this isn't a great solution, but it's just an example.
The easiest way to have flexible build schedules is use an external source to drive your builds. The hook mentioned in the comments would be ideal, but it sounds like that is not possible for you. Another idea would be to have a cron job on your database server that runs once a day, grabs the build time from the database, and schedules the build for that time. I'm sure this isn't a great solution, but it's just an example.
Context
StackExchange DevOps Q#10447, answer score: 1
Revisions (0)
No revisions yet.