To trigger build retention when publishing build-info to Artifactory, use the following method:
buildInfo.retention maxBuilds: 10
buildInfo.retention maxDays: 7
To have the build retention also delete the build artifacts, add the deleteBuildArtifacts with true value as shown below:
buildInfo.retention maxBuilds: 10, maxDays: 7, doNotDiscardBuilds: ["3", "4"], deleteBuildArtifacts: true
It is possible to trigger an asynchronous build retention. To do this, add the async argument with true as shown below:
buildInfo.retention maxBuilds: 10, deleteBuildArtifacts: true, async: true