Skip to content

Instantly share code, notes, and snippets.

@bigboy1122
Forked from hgomez/jenkins-set-credis.groovy
Created March 26, 2016 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigboy1122/e968497f04bcb2ea80e9 to your computer and use it in GitHub Desktop.
Save bigboy1122/e968497f04bcb2ea80e9 to your computer and use it in GitHub Desktop.
Jenkins Groovy script to set CredentialsId
import hudson.model.*
import hudson.maven.*
import hudson.tasks.*
import hudson.scm.*
def match_url = "http://svn.mycorp.com/svn/devops"
for(item in Hudson.instance.items) {
hasClaim = false;
if (item.scm instanceof SubversionSCM)
{
for(location in item.scm.locations) {
if (location.remote.startsWith(match_url)) {
println("\n@@@@@@@@@@@@@@@@@")
println("\njob $item.name")
println("\n@@@@@@@@@@@@@@@@@")
println("\nlocation $location.remote")
credid = location.credentialsId
if (credid != null)
println("\ncredid $credid")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment