How to delete build parameter from all jobs?

Issue

How do i delete a build parameter from all jobs?

Environment

  • CloudBees Jenkins Enterprise

Resolution

You can run the following from the Script Console ( $JENKINS_URL/script):

import hudson.model.*

  recurseChildren(Hudson.instance.items)

  def recurseChildren(items) {
    items.each { item ->
      if (item.class.canonicalName != 'com.cloudbees.hudson.plugins.folder.Folder') {
        props = item.getProperty(ParametersDefinitionProperty.class)
        if (props != null) {
          props.getParameterDefinitions().removeAll { 'MY_BUILD_PARAM' == it.name }
        }
      } else {
          recurseChildren(((com.cloudbees.hudson.plugins.folder.Folder) item).getItems())  
      }
    }
  }

Replace MY_BUILD_PARAM with the build parameter you want to bulk delete.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.