From: Trevor Bramwell Date: Tue, 15 May 2018 14:09:42 +0000 (-0700) Subject: Remove Unused Jenkins-Admin Groovy Scripts X-Git-Tag: v0.22.0~2^2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F36%2F10636%2F1;p=releng%2Fglobal-jjb.git Remove Unused Jenkins-Admin Groovy Scripts These scripts: - del_computer.groovy - get_all_creds.groovy - slay_computer.groovy Were added a few months back but aren't used by any jobs. Change-Id: I53ed4f1a0451c7a96301352be63a451a03bd803c Signed-off-by: Trevor Bramwell --- diff --git a/jenkins-admin/del_computer.groovy b/jenkins-admin/del_computer.groovy deleted file mode 100644 index 01438870..00000000 --- a/jenkins-admin/del_computer.groovy +++ /dev/null @@ -1,39 +0,0 @@ -/***************** -* Removes offline slave nodes -* -* NOTE: Some slaves can't be removed as the backing instance already is -* missing but the UI collection didn't get the update. See the -* slay_computer.groovy for a more drastic destruction -* -* NOTE 2: If you have any slaves you want to live through this and you -* have them currently marked offline you _must_ bring them back online. -*****************/ - -import hudson.model.* - -def numberOfflineNodes = 0 -def numberNodes = 0 - -slaveNodes = hudson.model.Hudson.instance - -for (slave in slaveNodes.nodes) { - def computer = slave.computer - numberNodes ++ - println "" - println "Checking computer ${computer.name}:" - if (computer.offline) { - numberOfflineNodes ++ - println '\tcomputer.isOffline: ' + slave.getComputer().isOffline() - println '\tcomputer.offline: ' + computer.offline - println '\tRemoving slave' - slaveNodes.removeNode(slave) - } else { - println '\tcomputer.isOffline: ' + slave.getComputer().isOffline() - println '\tcomputer.offline: ' + computer.offline - } -} - -println "Number of Offline Nodes: " + numberOfflineNodes -println "Number of Nodes: " + numberNodes - -// vim: sw=4 sts=4 ts=4 et ai : diff --git a/jenkins-admin/get_all_creds.groovy b/jenkins-admin/get_all_creds.groovy deleted file mode 100644 index 13a5b2a9..00000000 --- a/jenkins-admin/get_all_creds.groovy +++ /dev/null @@ -1,25 +0,0 @@ -/***************** -* Extracts all registered credentials and passwords -* -* Jenkins credentials are encrypted and passwords cannot be retrived easily. -* Run this script to get all credentials pairs in an "Id : Password" format. -* Note: This script will not display information for SSH and Certificate -* credential types. -* -*****************/ - -import com.cloudbees.plugins.credentials.* - -println "Printing all the credentials and passwords..." -def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials( - com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class, - Jenkins.instance, - null, - null -); - -for (c in creds) { - try { - println(c.id + " : " + c.password ) - } catch (MissingPropertyException) {} -} diff --git a/jenkins-admin/slay_computer.groovy b/jenkins-admin/slay_computer.groovy deleted file mode 100644 index 97ede6cd..00000000 --- a/jenkins-admin/slay_computer.groovy +++ /dev/null @@ -1,35 +0,0 @@ -/***************** -* Completely slays misbehaving slave nodes -* -* NOTE: Use del_computer.groovy first! If nodes are still hanging around -* _then_ consider using this script. This one is mucking around in a -* location we should not normally be touching, however if a slave -* refuses to go away (tosses an exception) this _will_ get rid of it. -* -* NOTE 2: If you have any slaves you want to live through this and you -* have them currently marked offline you _must_ bring them back online. -*****************/ - -import jenkins.* -import jenkins.model.* -import hudson.* -import hudson.model.* - -for (aComputer in Jenkins.instance.computers) { - try { - println "displayName: " + aComputer.properties.displayName - println "offline: " + aComputer.properties.offline - println "temporarilyOffline: " + aComputer.properties.temporarilyOffline - if (aComputer.properties.offline) { - println "Bad node, removing" - Jenkins.instance.removeComputer(aComputer) - } - println "" - } - catch (NullPointerException nullPointer) { - println "NullPointerException caught" - println "" - } -} - -// vim: sw=4 sts=4 ts=4 et ai :