Child pages
  • Remove Deployed Artifacts Actions
Skip to end of metadata
Go to start of metadata

This script is used to remove the Deployed Artifacts list that is uselessly stored for each build by the Artifact Deployer Plugin.


import hudson.model.*

hudsonInstance = hudson.model.Hudson.instance
allItems = hudsonInstance.items

// Iterate over all jobs and find the ones that have a org.jenkinsci.plugins.artifactdeployer.DeployedArtifacts
// as an action.

def jobCounter = 0;
def totalBuildCounter = 0;

for (job in allItems) {
  def buildCounter = 0;
  for (build in job.getBuilds()) {
    // It is possible for a build to have multiple actions
    def adActions = build.getActions(org.jenkinsci.plugins.artifactdeployer.DeployedArtifacts.class)
    if (adActions != null && !adActions.isEmpty()) {
      for (action in adActions) {
        build.actions.remove(action)
      }
      build.save();
      buildCounter++;
    }
  }
  if (buildCounter > 0) {
      println("Job: " + job.name + " cleaned " + buildCounter + " builds");
      jobCounter++;
      totalBuildCounter += buildCounter;
  }  
}

println("Cleaned " + jobCounter + " jobs and a total of " + totalBuildCounter + " builds");

  • No labels