Build-timeout Plugin in Jenkins: how long is 'too long'? - jenkins

I would like to take advantage of this plug-in but the 'Abort the build if it's stuck' option doesn't set any timer and the description of the plug-in doesn't say how long is the timer, it just says: 'This plugin allows you to automatically abort a build if it's taking too long'
My question is how long is that? 1 hour, less/more?
Can I set up my own time?
Is that timer for the overall job or every line in the batch file has that timer?

Build-timeout plugin has multiple options (taken from help documentation of Build Timeout Plugin)
Absolute time. Use this if you know exactly how much time your build should not exceed in advance
Elastic time. Use this option if you want Jenkins to decide on the time. It basically averages out on the last n builds and will stop a
build if it exceeds given percentage. If you do not know in advance
how much time your build takes, use this option
Likely Stuck. Use Jenkins' Executor.html#isLikelyStuck() heuristics based approach to detect build is suspiciously taking for a long time
In your case, option two seems to be best initially.

I upgraded my jenkins installations recently to 1532 and noticed on jobs that the radio to set time has gone missing. I may file this as a bug.
This is what it should look like on your jobs:
https://github.com/jenkinsci/build-timeout-plugin/pull/14#issuecomment-24114825

I just upgraded to Jenkins 1535 and with that a new upgrade of the plug-in was available. That upgrade fixed the problem I was having. The timeout time is now available.

Related

How to abort a Jenkins Job programmatically at a specified time

I want to abort my Jenkins Job before clock hits a particular time. I didn't find anything which stops it automatically at a specified time(I don't want to do it manually). Is there anything like that?
I have read this post, but none of the answer solves my problem How to stop an unstoppable zombie job on Jenkins without restarting the server?
If you want to stop a long running job, let's say, it is running more than 3 hours, then below jenkins plugins does exactly that for you.
Abort a build if it is likely stuck
Or, if you want certain build to abort on a specific time (i.e, no build should run at 5 pm daily), then you can configure groovy script to do that.

Jenkins build is not timing out even when Build Timeout is explicitly mentioned

I've mentioned build timeout in jenkins job as per attached screen shot
But even with this setting build is not timing out even after 2 -4 hrs.
I use jenkins job to do GET requests to REST end points.
There is a bug with one of the end point which results in response not being sent in required time.
Please clarify how to get time out fixed with jenkins job ?
Thanks & Regards,
Vikram
The "Abort the build if it's stuck" option is offered by the "Build Timeout Plugin".
According to the documentation of the "Build Timeout Plugin" (https://wiki.jenkins-ci.org) :
[...] depending on how a build hangs, the abort operation might not take effect.
The documentation lists a couple of possible reasons. Make sure you are not affected by one of those reasons. (I cannot tell without seeing a lot more of your configuration and precisely how you place those GET requests.)

Jenkins: trending graph for build step time

My project has about 20 build steps and i want to monitor how much time each step takes over builds. I found Jenkins doesn't display such info.
Can use any of Jenkins tools or plugin to do that?
Was just looking for the same and found your post. There is this plugin though it doesn't show you a nice graph or anything it will add the raw timestamps to your log lines on a per project basis. https://wiki.jenkins-ci.org/display/JENKINS/Timestamper If you install it you have to configure each project separately to check the add timestamps to console box (there is a script for doing all projects at once but I didn't want to chance that and only need it to diagnose a particularly slow build).
Did you try this. Makes sense to your case.
https://wiki.jenkins-ci.org/display/JENKINS/build-metrics-plugin

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"

Jenkins share build number across jobs?

We are currently developing an app with multiple parallel streams of development. We have a Jenkins job to build each stream/release. So Job-A may be building release 1.1, and Job-B may be building release 1.2.
I think it would be best to have the build number shared across each release, such that if Job-A runs with build number 125, if Job-B runs next it will run with build number 126. The reason I think this is the best strategy is that this is an Android app, which requires its versionCode parameter to be incremented each time it's submitted to Google Play. We use the Jenkins build number for the versionCode value.
Is there any way to configure Jenkins to share a build number across multiple jobs? Or, has anyone come up with a better solution to this problem?
short answer use timestamps or manually set versionCodes, keep things out of the CI server when not necessary. Or force the jenkins build numbers.
long answer I like jenkins to be responsible for automating something that also works on its own. So if I don't need jenkins for the setup, I am happy as well.
Also if you use 2 branches, you probably commit in random orders into them. Trying to tie the jobs together in some ways seems like an unnecessary trouble that could be a problem later on. E.g. what if version 2.0 is built and QAed now, just waiting for the proper release date and marketing team to complete its job, but you need to release a v1.1.1 quick fix after that ? Depending on the solution you pick, you may need to trigger some rebuilds to force a versionCode bump. New build, new QA ?
Your real requirement for the versionCode is for it to be higher than the previous release.
From http://developer.android.com/guide/topics/manifest/manifest-element.html
android:versionCode An internal version number.
This number is used
only to determine whether one version is more recent than another,
with higher numbers indicating more recent versions. This is not the
version number shown to users; that number is set by the versionName
attribute. The value must be set as an integer, such as "100". You can
define it however you want, as long as each successive version has a
higher number. For example, it could be a build number. Or you could
translate a version number in "x.y" format to an integer by encoding
the "x" and "y" separately in the lower and upper 16 bits. Or you
could simply increase the number by one each time a new version is
released.
So here are 2 solutions:
manual bumping. In our projects, I use some sed scripts to automate the bumping of the build number before release. As I also need to change a few things by hand, like versionName prefix, disable/enable debugging mode during development, etc, I manually run a bumpversion script so that next build in my branch has appropriate version and versionCode numbers. Note I use the jenkins build number in versionName instead. This solution prevents you from having the 1.1.1 needs to be out after v2 is ready problem if you pick a large enough versionCode bump for v2.
another more automated yet still simple solution would be to use something out of timestamps. The format YYMMDDHHSS is good enough of an integer (< 2^31), and chances are that whatever version you are going to release next is going to be prepared after the previous one and not within the same minute. So basically when you build v1.1, it gets e.g. 1308131600 and if you build v1.2 the minute after it gets 1308131601. (this obviously doesn't help you against the v1.1.1/v2 scenario)
Here are some ideas for scripts to generate/update versionCode Auto increment version code in Android app.
The jenkins way
Now if you still want jenkins in charge, a simple solution is to use something like https://wiki.jenkins-ci.org/display/JENKINS/Next+Build+Number+Plugin and configure your per branch jobs to have a large enough prefix to ensure no clash. The setup is still pretty simple.
E.g.
110000 for branch 1.1
120000 for branch 1.2
You could look at the multijob plugin where you can add multiple parameterised jobs in to a containing job
https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin
You could also look at artifact archiving Archive the artifacts in hudson/jenkins and then pick the files up later
I haven't tried it, but i'm thinking about going on to the build machine and in each of the jobs replacing the nextBuildNumber file with a symlink to a single file somewhere. What could possibly go wrong. Well, concurrent access might be an issue. There might be an issue if Jenkins re-creates the file from scratch, ie with a remove and a create, instead of just opening it as normal.

Resources