Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata

This script changes the configuration for the plugin: Publish Over SSH Plugin

It will change the configuration name from "bad-server" to "good-server" for FreeStyleProjects.

import java.util.*
import hudson.model.*
import hudson.maven.*
import hudson.maven.reporters.*
import hudson.matrix.*
import hudson.tasks.*
import hudson.util.DescribableList
import jenkins.plugins.publish_over_ssh.*
import jenkins.plugins.publish_over.*

hudson.model.Hudson.instance.items.findAll{job -> job.isBuildable() }.each{
job -> 

  if(job instanceof FreeStyleProject) {
    for (builder in job.builders){
      if(builder instanceof BapSshBuilderPlugin) {
        ArrayList<BapPublisher> publishers = builder.delegate.delegate.publishers
        
        for(publisher in publishers) {
          if (publisher.configName == "bad-server") {
            println "Changing job: ${job.name}"
            publisher.configName = "good-server"
          }
        }
      }
    }
  }
}
  • No labels