Daniel Beck commented on Bug JENKINS-21785

The following would be a rough outline of a script to run in Script Console that adds an Additional Credential (by copying the first location's credential) to all projects with known externals:

Jenkins.instance.getAllItems(AbstractProject).each { p ->
  if (p.scm instanceof hudson.scm.SubversionSCM) {
    if (p.scm.locations.size() == p.scm.getProjectLocations(p).size()) {
      println p.fullDisplayName
      // known externals
      if (p.scm.locations.size() == 0) {
        println "... no configured locations!?"
        return
      }
      def auth = p.scm.locations[0].@credentialsId
      if (auth == null) {
        println "... no auth for first location"
        return
      }
      if (p.scm.@additionalCredentials == null) {
      	p.scm.@additionalCredentials = []
      }
      p.s...@additionalcredentials.add(new hudson.scm.SubversionSCM.AdditionalCredentials('<https://svnserver:443> Subversion Authentication', auth))
      println "... adding additional credential"
      p.save()
    }
  }
}
return

Just replace the domain "<https://svnserver:443> Subversion Authentication" with whatever's correct for you. It's a bit rough around the edges (e.g. doesn't check whether there's already an Additional Credential for the specified realm, only reuses the first location's credential ID, doesn't check whether the credential domain matches the auth realm, ...), but it should be a start.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to