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

6.3k views Asked by At

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 :)

1

There are 1 answers

5
Gerold Broser On BEST ANSWER

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.