Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ChristopherDavenport/bc5ba7a33d5dd5fc975da81c4a270a90 to your computer and use it in GitHub Desktop.
Save ChristopherDavenport/bc5ba7a33d5dd5fc975da81c4a270a90 to your computer and use it in GitHub Desktop.
Jenkins create new node
#!/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="ssh-slaves@1.5">
<host>${NODE_NAME}</host>
<port>${SSH_PORT}</port>
<credentialsId>${CRED_ID}</credentialsId>
</launcher>
<label>${LABELS}</label>
<nodeProperties/>
<userId>${USERID}</userId>
</slave>
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment