Continuous Integration in Jenkins, Test Cases from 2 Builds are stacking up - jenkins

I have Continuous Integration Set up in Jenkins which is Triggered every time there is Code change, However if the change is done Frequently then the Test Cases from 2 Builds are stacking up. Is there a way to Cancel/Stop the Previous Builds Test Cases from Running, and just Continue with the latest Build

Try to use the 'Quiet Period' option. This is available from the 'Advanced' section of 'Configure'.
Here, you can specify how many seconds Jenkins should wait before actually starting its task after a commit has been made. So, if you provide 30 minutes (30*60 = 1800) as the quiet period, and you have made a commit at 8PM, Jenkins would wait till 8:30 PM before starting its task. In the meantime, if you make 2-3 more commits, they will be stacked together and considered during the 8:30 PM run.
Hope this helps

Related

How does Jenkins handle the following scenarios for long running builds?

I want to know what is the jenkins workflow in the following scenario.
Scenario 1:
Let's say a build job takes 30 minutes to complete and in the meantime the developers submit commits 1, 2 and 3 in the 1st minute and then commits 4, 5 are submitted in the 15th minute. Will jenkins create 2 separate build jobs in the queue if the polling frequency for SCM change is 1 minute? Or will it combine all the 5 commits into a single build job?
Scenario 2:
Also, what will happen if the quiet period is set to 5 minutes with SCM polling frequency set to 1 minute, and the long running build job is running and in the meantime 5 commits come at 1st minute, 4th minute, 11th minute, 15th minute and 16th minute after the previous build job was initiated? Will it still add two build jobs to the queue? Or will it combine these 5 commits into a single build?
If polling every minute, in scenario #1, Jenkins will start two separate jobs, one for commits 1, 2, and 3, and a second for commits 4 and 5.
For scenario #2, Jenkins will also create two jobs if the quiet period is 5 minutes, based on your example.
There are a few solutions that help address the problem of new and old builds running concurrently. One option is to use the Milestone Pipeline plugin to automatically abort multiple concurrent jobs running, once one of them has reached a milestone.
The second is that some SCM plugins, such as the GitHub plugin, support a build trigger Cancel build on update feature, that will automatically stop running jobs when a new job is triggered via an update.
A third option is to use a Groovy script that executes as part of the build, and detects running jobs for older commits and aborts them.

Jenkins Trigger X minutes after last build

We have recently switched from CruiseControl.Net to Jenkins for managing our builds. With CCNET it would trigger a new build X minutes after the last one completed, but with Jenkins it is constantly dropping builds in the queue, not allowing any time in between the two. We'd prefer the CCNET method.
I don't see how this can be done with the Scheduler Trigger, it seems to be all date time based.
I don't see any setting to prevent Queueing another build where the build is currently running.
I don't see a trigger that would allow for timing based off last run.
How could I manage this?
Jenkins lets you set a quiet period between builds, which can be set at the system level and overridden at the job level. Here's the help text from Jenkins:
If set, a newly scheduled build waits for this many seconds before actually being built. This is useful for:
Collapsing multiple CVS change notification e-mails into one (some CVS changelog e-mail generation scripts generate multiple e-mails in quick succession when a commit spans across directories).
If your coding style is such that you commit one logical change in a few cvs/svn operations, then setting a longer quiet period would prevent Jenkins from building it prematurely and reporting a failure.
Throttling builds. If your Jenkins installation is too busy with too many builds, setting a longer quiet period can reduce the number of builds.
If not explicitly set at project-level, the system-wide default value is used.
And here is a more detailed discussion.

Jenkins Build Periodically - Once

I am trying to schedule a Jenkins Deployment task to run only once.
Why? So no one has to log in remotely to do after hours deployments (No Fun!)
So my question is: Is there a way to specify year within jenkins' cron syntax?
More info:
Under Build Triggers -> Build Periodically
If I schedule a build for today(Thursday, June 10th) at 10:52 AM
The cron syntax would be 52 10 10 6 2
However, the next June 10th will occur in the year 2025, so technically, the build will still be scheduled for 11 years from now, unless I manually remove the schedule.
This is not a huge problem, it just doesn't make sense to me someone hasn't come up with a solution for it yet.
I am not looking for hacks, scheduled tasks, or scripting... All of that would be more work then just manually removing the schedule. I would like to keep this completely inside of jenkins
If this is truly impossible, I will consider writing a plugin for this specific use-case.
Well after much digging I finally found it:
https://wiki.jenkins-ci.org/display/JENKINS/Schedule+Build+Plugin
It adds ^^ the schedule build button to all projects which provides a nice UI to set a date and time, instead of dealing with that ridiculous cron syntax.
Jenkins' Modo should be "There's a plugin for that"

tfs build wait since last check-in

When I check-in a file, the TFS CI trigger waits very little and starts the build. The problem is that I may have 10-30 files to check-in, and I would like the TFS to wait at least 5 minutes after my last file checked in before it starts a new CI build. In Cruise-Control I had a "modificationDelaySeconds" property where I could set the minimum amount of seconds to wait after the last check-in. How do I do this in TFS (2012)?
The closest alternative in TFS is to define Rolling Builds (also known as Batched-CI-builds).
Change the build trigger from Continuous Integration to Rolling Builds. This way, the build waits till the last build has finished; you can also configure that you do not want to build more often than every 5 minutes.

TFS Rolling Build appears to skip building sometimes

Environment: TFS 2010
I met a strange issue on the TFS 2010.
I create a rolling build, and set it should be triggered no more often than every 30 minutes.
Usually, it works fine. I can find the build was triggered several times one day.
Then there is a long vacation and after I came back, the rolling build was not triggered in the last two days.
There is nothing changed for the build definition and TFS server.
It is very strange.
Does anyone know the reason or have the same situation?
BTW, I have a little question for rolling builds. That is, Rolling builds work when there are accumulate check-ins until the prior build finishes. If 1:00 AM, a rolling build was triggered, it will finish at 1:20. At 1:10 some new code was checked in, an other build such as nightly build was triggered before 1:20. Question: Is the rolling build triggered at 1:30?
The whole point of rolling builds is so they don't build up in a queue, basically it means if anyone checks in while a build is happening it won't trigger a build.
If you set a time, eg 30 minutes, it won't ever build within 30 minutes of a previous build.
For the next build to happen you need to check in again outside of those conditions (eg 30 minutes later)

Resources