Assumptions:
- Windows-to-Windows only since it uses Windows specific tool (PsExec.exe).
- Target Slave machine has svn command-line client installed because the script would make slave PC to checkout the scripts first from an svn repo.
- Will only work with lower versions of Jenkins (specifically, Jenkins versions that are built against Java 7 and below)
Approach:
- The main script (slave_launcher.bat) would connect to the remote Slave Windows machine via PsExec.exe
- Arguments in order:
- jenkinsIP= Jenkins URL of mater, ex: http://localhost:8080
slaveIP=IP of the target Slave machine
slaveUsr=user cred to slave machine
slavePw=password
launcherSVNPath= source repo location for this tool, ex: svn://svnhost:5800/CI_Script/batch/ci_slave_launcher
wait=Timeout in sec to wait for Jenkins slave to launch before exiting the script
- jenkinsIP= Jenkins URL of mater, ex: http://localhost:8080
- Arguments in order:
- Checks out the tool in the remote slave server
- Executes kill.bat - which kills any running "javaw.exe" process. Our machines launch javaw.exe for Jenkins only. If your machine is using javaw.exe for other purposes, you have to modify this part.
- Executes generate_slave.bat - generates the new slave bat file with values supplied in main script then runs it.
Main Script: slave_launcher.bat
Sample command: slave_launcher.bat http://localhost:8080 10.69.243.14 user1 password123 svn://svnhost:5800/CI_Script/batch/ci_slave_launcher
Final notes:
- PsExec.exe is glitchy. It may not run at first attempt but could become successful on the second try. Test it out part by part first.
- Creating a job in your Master jenkins for this script can be helpful.
- Again, modify as per your need, ex replacing "svn checout" with "FTP transfer", etc. This was just an impromptu script that we had to do because of the sheer number of slaves that we had to maintain.
0 comments:
Post a Comment