Is there a way to lock down deployments to only be during a specific time of day? - jenkins

I want to be able to only deploy anytime between 9:00am and 6:00pm on certain days. I already have the builds locked down by day using "Set approvedDays" but I need one for hours.

Maybe this Jenkins plugin could solve your problem: https://github.com/jenkinsci/working-hours-plugin

Related

Schedule job at specific dates

How to :
Schedule job at specific dates across several months ?
it will be ~10 dates.
Second is there a tool that simulate cron, such that u can pass date/time and the tool tell you did cron triggers or not
cron does not schedule events in that manner. Jenkins scheduler is cron-based.
This answer provides several options.
Apparently there is now a released plugin - Schedule Build which appears to support calling the scheduleBuild action referenced in my groovy based answer.
See constraint (you can only schedule one build at a time) unless parameterized.

How to schedule an on-premise Azure DevOps build to run every 5 minutes?

Never mind the rationale, I have a case where a build needs to run every 5 minutes. On-premise installation does not support schedules in the YAML.
So, how do we do it? I can probably use the REST Api, but that sucks, because it seems either I create a one-off script or a script for very simple type of schedules. Building a reusable solution, that could be used in general for other builds seems to be involved. So, instead of concentrating on my business I need to go sideways and cover for the deficiencies of the on-premise version of Azure DevOps.
I wonder if there is a better way.
Understand your concern. However, this is not supported at present with on-premise TFS sever.
The UI for defining time-based build triggers isn't flexible enough. It can only support fixed times on days of the week.
Just as you have pointed out in the comment, we have a need to run a build every 5 minutes which requires us to create 288 schedules which is tedious.
Actually, this has already been a user voice.
Scheduled builds - More flexible timing configuration
https://developercommunity.visualstudio.com/idea/365630/scheduled-builds-more-flexible-timing-configuratio.html
Multiple persons commented and echoed. After go through the marketplace, haven't found a pretty appropriate workaround. Sorry for any inconvenience. You could monitor the status of above user voice.

how should I do the scheduling

I have never written a windows service or any scheduler before so I couldn't figure out what to do.
I need to write a windows service. There is a Report table in my DB, and I need to check it every day to see if there are new reports added. Reports have receivers and the time settings, such as 15th of every month at 14:00, or daily at 12:35 or weekly on Wednesdays at 13:00. And I need to send emails with some reports at these times.
As I have decided, I will use Quartz.NET. But there are a couple of things I don't understand. So I will have 2 Jobs I think. One for checking the DB every day, to see if there are new reports that users want. And when I receive them, I'll create new different amount of Jobs with new triggers based on the times in the DB? Do I create new triggers in the job of the first daily check? I didn't understand it.
And when for example a time of one report is updated, or deleted, Do I need to delete the Job and the trigger from the scheduler? I'd appreciate the help. I am using VS 2015 with C#.
And when I do the windows service, I'll just initiate this Quartz thing that I have written? Sorry I couldn't understand what I have read so far.
I would recommend Hangfire IO over Quartz.net
http://hangfire.io/
Its a more modern approach to scheduled jobs. In the past I've used Quartz.net as well. First of all, using hangfire requires no service. The jobs are persistent, and retries are built in. The syntax is also easier.
I've used hangfire and its wonderful and simple.
however, Hangfire does not support Oracle db so far. Also Quartz provide more flexibility in terms of scheduling (calendars, end dates etc).

Should I use Delayed Job for long running background tasks?

I have an application where I want to automatically deactivate a user 72 hours after they have been activated. I have set this up with Delayed Job, but am now wondering if that is the best option.
My question is, if I set a task for 72 hours in the future, will a worker be active for that entire 72 hours? (I'm concerned about this as Heroku charges by the hour)
I'm open to suggestion here as far as better ways of doing this goes. One idea I had was to set this up using an exp_date column and check against that at sign in there by eliminating the need for DJ completely.
My question is, if I set a task for 72 hours in the future, will a worker be active for that entire 72 hours? (I'm concerned about this as Heroku charges by the hour)
Yes, it will be up all time. Delayed job continuously pings the database to see if there any job in its queue.
And, regarding the best option i think i rather put one column knows as valid_upto and put the date till will be active. I only signins (or whatever) to only those user which has created_at dates less then or equal to valid_upto date. And, periodically may be once in month i will run one cron job to remove invalid users.
And, like #leesungchul suggested, you can use that, that looks cool.
You can use the workless gem which is an addon for delayed jobs so you don't leave your worker running constantly on heroku.
https://github.com/lostboy/workless

Managing timezones for different users

I have a website where I have many users coming from different countries. Users can schedule a task based on their timezone. Now there is a cron running on the server after every min, the cron executes a script which checks if there are any scheduled task of any user and if so it does the needful.
Since my server is based in the US, the script executed by the cron considers the timezone of the US. What do I have to do in my script that will execute the user's task based on user's timezone instead of server's timezone?
Thanks in advance for any ideas
Lookup the user's timezone.
Compute the current time in the user's timezone.
For each job, look up the last time it was run and compute the next time it should run.
For any job whose next run time is now or in the past, run that job and update the record of the last time each job was run.
I did something similar on the iPhone a few months ago.
My solution was to capture the time as a string. So if the user selected 8am, I would just capture 08:00 and their time zone e.g. Europe/London.
Every 5 minutes or so on my server, I could then convert this 08:00 into the current UTC time based on the timezone. If this time was "present", I would carry about a check on the user's transport status and issue alerts.
To help me with the TimeZones, I used NodaTime. http://noda-time.blogspot.co.uk/

Resources