-
-
Save sergeyhush/4e892837cf5c31c3d242 to your computer and use it in GitHub Desktop.
| #!/bin/bash | |
| JENKINS_URL=$1 | |
| NODE_NAME=$2 | |
| NODE_SLAVE_HOME='/home/build/slave' | |
| EXECUTORS=1 | |
| SSH_PORT=22 | |
| CRED_ID=$3 | |
| LABELS=build | |
| USERID=${USER} | |
| cat <<EOF | java -jar ~/bin/jenkins-cli.jar -s $1 create-node $2 | |
| <slave> | |
| <name>${NODE_NAME}</name> | |
| <description></description> | |
| <remoteFS>${NODE_SLAVE_HOME}</remoteFS> | |
| <numExecutors>${EXECUTORS}</numExecutors> | |
| <mode>NORMAL</mode> | |
| <retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/> | |
| <launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="[email protected]"> | |
| <host>${NODE_NAME}</host> | |
| <port>${SSH_PORT}</port> | |
| <credentialsId>${CRED_ID}</credentialsId> | |
| </launcher> | |
| <label>${LABELS}</label> | |
| <nodeProperties/> | |
| <userId>${USERID}</userId> | |
| </slave> | |
| EOF |
OK, i finally find the config under /jenkins_home/nodes/.../config.xml
hey @sergeyhush , this was crazy useful, thanks. i think the dollar sign in RetentionStrategy$Always needs to be escaped with one backslash in order for it to get through correctly. a comment showing usage of get-node in here might also be hot, since i learned about that elsewhere and it was useful to get multiple nodes looking the same.
java -jar ~/bin/jenkins-cli.jar -s $1 get-node $2
you are the man!
Thanks man.
I got a 'java.net.MalformedURLException: no protocol: JENKINS_URL' exception when I tried to create a new node with your script.
Is it because of wrong URL ? I tried different url but none success
Thanks, very helpful script.
why I run java -jar jenkins-cli.jar -s https://test.myaddress.com/ help which don't anything output? thanks!
SSL/TLS issues probably
Hi,
how do I obtain the Cred_ID ?
hello, may I ask how you find the schema for this slave configuration? I would like to use options other than provided above.
thanks a lot.