13

I am in the process of connecting a static slave to Jenkins master. The command Im going to use is :

java -jar <PATH>/slave.jar -jnlpUrl $JENKINS_MASTER_URL -secret $JNLP_SECRET

My question is where does the $JNLP_SECRET secret come from ?

If its something configured in the Jenkins Master, then where is it configured ?

And if I have access to that, can I just cope paste it into this command ?

A short explanation or link to documentation will be appreciated.

2 Answers2

10

I don't have the "where did the value come from" knowledge, but if you are a Jenkins administrator you can login to Jenkins, Manage Jenkins, Script Console, then run this script (script from here: JENKINS-18342):

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

Also this documentation describes how you could do it if you aren't a Jenkins admin: How to find JNLP Node's secret key remotely

Brad Albright
  • 686
  • 7
  • 12
3

The JNLP_SECRET is passed as part of the slave-agent.jnlp you download to start your Jenkins slave.

You can extract the secret from this file as described here:

You can download the “slave-agent.jnlp” file at $NODE_URL/slave-agent.jnlp. This file actually contains XML content that includes the secret.

Here is an example of a JNLP file downloaded from a Jenkins instance at https://cje.example.com/computer/jnlpAgentTest/slave-agent.jnlp - the secret is b8c80148ce36de10c9358384fac9e28fbba941055a9a6ab2277e75ddc29a8744:

  <jnlp codebase="https://cje.example.com/computer/jnlpAgentTest/" spec="1.0+">
      <information>
          <title>Agent for jnlpAgentTest</title>
          <vendor>Jenkins project</vendor>
          <homepage href="https://jenkins-ci.org/"/>
      </information>
      <security>
          <all-permissions/>
      </security>
      <resources>
          <j2se version="1.8+"/>
          <jar href="https://cje.example.com/jnlpJars/remoting.jar"/>
      </resources>
      <application-desc main-class="hudson.remoting.jnlp.Main">
          <argument>b8c80148ce36de10c9358384fac9e28fbba941055a9a6ab2277e75ddc29a8744</argument>
          <argument>jnlpAgentTest</argument>
          <argument>-workDir</argument>
          <argument>/tmp/jnlpAgenttest</argument>
          <argument>-internalDir</argument>
          <argument>remoting</argument>
          <argument>-url</argument>
          <argument>https://cje.example.com/</argument>
      </application-desc>
  </jnlp>
Community
  • 1
  • 1
Michael Powers
  • 1,970
  • 1
  • 7
  • 12