Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid large log Jenkins file (and stop build if needed)

We are using Jenkins (on Linux) to manage our Maven builds.

Our users can create their own job and sometimes (3 or 4 times per year), they are doing a mistake and the job generates a large log file (79 GB the last time...).

I had a look to existing plugins and I didn't find something to monitor the Jenkins log size.

For example, if the log size exceeds 200MB (when the job is running), I would like to automatically stop the build.

If you developed such shell scripts or Jenkins plugins, can you share your solution?

Thanks :)

like image 397
Bruno Lavit Avatar asked Jun 12 '15 14:06

Bruno Lavit


People also ask

How do you limit the number of builds stored in the build history in Jenkins?

This is a feature that is given to you by Jenkins so you can change the number of builds you want to keep. If you are using a Declarative pipeline you can just add this to your code: pipeline { options { buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '30')) } ... }


1 Answers

You can use the Logfilesizechecker Plugin:

This plugin monitors the size of the output file of a build and aborts the build if the log file gets too big.

Or, if this has also an impact on the runtime, the Build-timeout Plugin:

This plugin allows you to automatically abort a build if it's taking too long. Once the timeout is reached, Jenkins behaves as if an invisible hand has clicked the "abort build" button.

like image 108
Gerold Broser Avatar answered Nov 16 '22 04:11

Gerold Broser