Avoid keeping artifacts on the Jenkins controller after they were deployed by 'Deploy artifacts to Maven repository' post-build action

1 minute read

Issue

  • Artifacts are stored on the Jenkins controller after the artifacts were deployed to Nexus via the "Deploy artifacts to Maven repository".

  • You are getting out of disk space on the controller.

Resolution

"Deploy artifacts to Maven repository" requires the archived artifacts so that they can be deployed when the build completes. That’s why disabling archiving (<archivingDisabled>true</archivingDisabled>) breaks it.

The only option to keep using "Deploy artifacts to Maven repository" while reducing the storage is to decrease the number of the archived artifact to 1 (<artifactNumToKeep>1</artifactNumToKeep>).

Additional notes:

  • You can use the Configuration Slicing plugin to update the value of artifactNumToKeep all jobs.

  • The cleanup of old artifacts is done at the beginning or the end of each build thus you’ll have to wait for builds to start to do the cleanup (or you can manually trigger it if you have the CloudBees Disk Usage Simple plugin).