Reputation: 213
so I have a Jenkins running with a slave. For this slave I have a scheduler which schedules jobs once per day.
Sometimes the scheduler doesn't finish after 24 hours, which is fine. The environment is very unique and sometimes this happens.
The problem here is that the scheduler will schedule the jobs after 24 hours - no matter what. What I have then is a scheduler still running on the slave and the same scheduler is scheduled a second time and waiting till the previous one is done. Adding things up the slave will never be free.
What I want is a scheduling option which says "schedule this scheduler on the slave. If this scheduler is still running on this slave - nevermind, forget it and lets see how things will be in 24 hours."
Anybody got a solution to this?
Thanks for help!
PS: It's a Windows server.
Upvotes: 2
Views: 614
Reputation: 7385
You could define a scheduling job which just looks if the job is running and if not triggers your long running job. You could write a script which checks the status, for example:
$r = Invoke-Webrequest http://host/jenkins/job/PROJECTNAME/lastBuild/api/xml?depth=1
if ($r.Content -like '*<building>false</building>*')
{
echo "all go"
}
else {
throw 'job still running'
}
And just add triggering another job in case of success.
EDIT: It is a powershell script. I assumed you are using windows.
Upvotes: 0