Legacy Knowledge Base
Published Jul. 2, 2025

Monitoring Disk Usage for Jenkins

Written By

Bernard De Luna De Luna

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

It is helpful to see how close you are to running out of space on Jenkins. We
have provided a way to see the current disk usage of the CI service. Login to
the Jenkins service and navigate to "Disk Usage" on the sidebar. When navigating
to this tab you will be presented with a breakdown of the disk usage of the
Jenkins home directory, `/var/jenkins_home`, and sub-directories.

This feature is available in versions >= `3.2.10` or `4.0.7`. Any significant
space consumed by the `/var/jenkins_home/workspace` folder should raise a red
flag. The `workspace` folder contains temporary folders for each build which
should be cleared after the build runs.

Managing Disk Usage for Jenkins

Automatic Cleanup of the Workspace Folder

Monitoring disk usage is just the first step. We also provide several ways to
avoid running out of space or addressing the "No space left on device" message.

The automatic cleanup of the folder `/var/jenkins_home/workspace` is handled by
the `cleanWs()` step included in the default pipeline embedded in our Jenkins
service.

post {
cleanup {
cleanWs()
}
}


If you are not already using the default Jenkinsfile and are still using the
Jenkinsfile included in your repository, we encourage you to upgrade to at least
version `3.2.0` and take advantage of the default pipeline as documented here.

Once you have deployed version `3.2.0`, one more step is needed to clear the
workspace folder. You must trigger a build for each branch or pull request in
Jenkins. This is because the `cleanWs` step happens after a build is run, not
when Jenkins starts up. After triggering manual builds on all of your branches,
navigate to "Disk Usage" on the sidebar, and you should no longer see the
`/var/jenkins_home/workspace` folder taking up significant space. The only time
this step will be required is when upgrading to the default Jenkinsfile. From
now on, as long as you are using the default pipeline, the workspace folder will
be cleared after every build.

Configuring Includes and Excludes

Performing lots of builds with many different branches or pull requests can
quickly consume the available disk space. To prevent this behavior set the
following environment variables on your CI service, with values customized to
your needs. Correctly managing these environment variables can save significant
space on the CI service.

LCP_CI_SCM_BRANCH_FILTER_INCLUDE
LCP_CI_SCM_BRANCH_FILTER_EXCLUDE

To give an example, setting `LCP_CI_SCM_BRANCH_FILTER_INCLUDE=master develop`
would only build the `master` and `develop` branches, while setting
`LCP_CI_SCM_BRANCH_FILTER_EXCLUDE=PR-*` would exclude all pull request builds.

Typically you'd first set the `LCP_CI_SCM_BRANCH_FILTER_INCLUDE` to the pattern
of branches you want to include. It is exclusive so all other branches which do
not match will be ignored.

Then if you have an exception that matches `LCP_CI_SCM_BRANCH_FILTER_INCLUDE`,
you would add that to `LCP_CI_SCM_BRANCH_FILTER_EXCLUDE`. You can use `*` as a
wildcard matcher at the end of a branch name. Branch names should be separated
by a whitespace character.

Did this article resolve your issue ?

Legacy Knowledge Base