Created
October 29, 2018 23:06
-
-
Save allyunion/09a9af4ce75772f97b6adf5736d4b87a to your computer and use it in GitHub Desktop.
Add a Jenkins Slave node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SLAVE_NAME=$1 | |
CREDENTIALS_ID=<INSERT_CREDENTIALS_HERE> | |
# USERNAME & PASSWORD is read from Jenkins credentials | |
cat <<EOF | java -jar /var/lib/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080/ create-node ${SLAVE_NAME} --username $USERNAME --password $PASSWORD | |
<slave> | |
<name>${SLAVE_NAME}</name> | |
<description>A Jenkins Slave node</description> | |
<remoteFS>/home/jenkins</remoteFS> | |
<numExecutors>5</numExecutors> | |
<mode>NORMAL</mode> | |
<retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/> | |
<launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="[email protected]"> | |
<host>${SLAVE_NAME}.example.com</host> | |
<port>22</port> | |
<credentialsId>${CREDENTIALS_ID}</credentialsId> | |
<maxNumRetries>0</maxNumRetries> | |
<retryWaitTime>60</retryWaitTime> | |
</launcher> | |
<label>slave</label> | |
<nodeProperties/> | |
<userId>${USERNAME}</userId> | |
</slave> | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment