Jenkins schedule: avoid job execution on when building scheduled job - jenkins

I scheduled a job in Jenkins to run each day at 1800 stopping some process. After I made configuration in Jenkins I build the job but it executed immediately and then moved over to the schedule. Can I prevent that first run somehow so let's say I build job at 1400 but it only executes at 1800 and not at 1400 when built?

Related

How to execute only 1 job build at a time in Jenkins

I have only 1 job in Jenkins. This job gets build multiple number of times. I want Jenkins to execute only 1 build at a time and keep remaining builds (to be executed next) in the build queue. I have changed the no. of build executors available from 2 to 1, still some part of the next build gets executed along with the current build. How to achieve this?
So I searched and learnt how Jenkins actually works, even if your build is in build queue and is waiting for an executor, it will still have building state as TRUE. So eventually only one build will be executed at a time but all those other builds in the queue will also be in building phase waiting for an executor.

how to add a delay in downstream project before it gets triggered by upstream project in jenkins

I have two Jobs configured on Jenkins job-A is upstream and job-B is downstream. once job-A completes the execution it triggers job-B but i want job-B should get start at least 5/10 minutes after job-A Completes. And in this case job-A starts at any random time in a day
Use Jenkins Quiet Period feature to add some wait time before starting build.
Quiet-Period: Number of seconds to wait between consecutive runs of this job.
This can be configured at Jenkins global level or each individual Job level.
In your case configure Job-B with Quiet Period 5 or 10 minutes.

How to run a job periodically and only if it's not already running on Jenkins

Let's say I have a Jenkins job which runs every 5 minutes and takes only 3 minutes to run, then the job suddenly became to take more than 5 minutes (say 8 minutes). In this case the job queue becomes full as Jenkins blocks the execution of newly added job until the already running job is finished.
I could allow concurrent execution of jobs in the queue, but I prefer that the newly added job is immediately cancelled if the last job is still running. Is this possible for Jenkins? Or should I look for more sophisticated job scheduling solutions?
If there is already a pending job in the queue, a next scheduled job is cancelled automatically. So the queue shouldn't be full of pending jobs even if a running job takes twice or much longer than the scheduled period.
I think you can use the "Prepare an environment for the run" scripts. When the second job starts up, you can search the build nodes to see if the same job is currently running, and cancel the queued up job. I found this with more information:
Cancel queued builds and aborting executing builds using Groovy for Jenkins

How to prevent parallel execution of two downstream jobs triggered from two different upstream jobs

I have Job A which triggers two downstream jobs, say Job B and Job C. These two downstream jobs executes in parallel on master node. Job B then triggers another job say job 1 on a slave node and job C triggers job 2 on the same slave node almost at the same time. Number of executors configured on this slave node is 1 as i don't want job 1 and job 2 to run concurrently. Job 2 gets queued since job 1 is already running on that slave node. But when job 1 finishes execution, job 2 runs into executor starvation and gets stuck.
Issue:- Job 2 is running into executor starvation and gets stuck.
Is there any way in which once job 1 finishes execution, job 2 starts running instead of getting stack. i have also tried Throttle concurrent builds plugin but still the issue persists.
Thanks in advance!
There are several plugins that allow resource management:
https://wiki.jenkins-ci.org/display/JENKINS/Lockable+Resources+Plugin
https://wiki.jenkins-ci.org/display/JENKINS/Exclusion-Plugin
https://wiki.jenkins-ci.org/display/JENKINS/External+Resource+Dispatcher
Some block the job from executing, others have the job "wait" for the resource (while job is running).
You would have to setup your Job1 and Job2 to use some resource, so that they can wait for one another.

Running periodic build job in Jenkins in the interval of 1 hour between completion of previous build and start of next build

I have one Jenkins build job which run periodically every hour.
I want know is there any way where i can configure my Jenkins build in such a way that my next build starts 1 hour after the completion of previous build
You can use quiet period feature to do this.
Configure your job with your custom time period ( 3600s ), and trigger the job when you build finish.

Resources