How to find slave secret key?

Issue

I have got the jenkins-cli working and able to create a slave. How can I dynamically get the secret key to start up the slave? The launch method is via Java Web Start.

Environment

  • CloudBees Jenkins Enterprise
  • CLI

Resolution

If you want to find/use the slave secret you can query the script console remotely.

Example:

for (aSlave in hudson.model.Hudson.instance.slaves)
{ println aSlave.name + "," + aSlave.getComputer().getJnlpMac() }

then pass the value to -secret.

For SharedAgents you can instead use the Groovy script below at OC level.

Jenkins.getInstance().getItems(com.cloudbees.opscenter.server.model.SharedSlave.class).each {
  // Selecting JocJnlpSlaveLauncher
   if (it.launcher != null && it.launcher.class.name == 'com.cloudbees.opscenter.server.jnlp.slave.JocJnlpSlaveLauncher'){
     println "--------------"
     println "Name:" + it.name
     println "Secret:" + it.launcher.getJnlpMac(it)
     println "--------------"
   }  
}

See also:

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.