Last active
December 14, 2015 23:28
-
-
Save djangofan/5165442 to your computer and use it in GitHub Desktop.
Runs a Jenkins slave server as a non-service so that the node can execute Selenium tests.
This file contains 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
@ECHO off | |
IF NOT EXIST jenkins-cli.jar ( | |
"C:\Program Files (x86)\GnuWin32\bin\wget.exe" --dot-style=binary http://localhost:8000/jnlpJars/jenkins-cli.jar | |
) | |
java -jar jenkins-cli.jar -s http://localhost:8000 build "Test Suite" | |
ECHO. | |
ECHO Test result can be found at: http://localhost:8000/job/Test%%20Suite/ | |
ECHO. | |
EXIT 0 |
This file contains 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
@ECHO off | |
SETLOCAL ENABLEDELAYEDEXPANSION | |
:: This runs a slave to a Jenkins master | |
:: running this script again will kill the Jenkins instance | |
:: | |
:: IMPORTANT: This script assumes the Jenkins master is installed separately | |
:: as a Windows service | |
:: | |
:: https://wiki.jenkins-ci.org/display/JENKINS/Starting+and+Accessing+Jenkins | |
SET PORT=8000 | |
TITLE Jenkins Slave Server on port %PORT% | |
IF NOT EXIST jenkins.war ( | |
ECHO The jenkins.war needs to be in this directory for this script to run. | |
ECHO Example location: C:\JenkinsSlave\jenkins.war | |
GOTO :CLEANUP | |
) | |
IF EXIST "%USERPROFILE%\.jenkins" ( | |
ECHO Jenkins home and configuration is probably at: %USERPROFILE%\.jenkins | |
:: configure workspace and build location in Jenkins advanced config in web interface | |
ECHO. | |
) | |
:: make sure Jenkins is not already running | |
netstat -a -n -o | FIND "%PORT%" >ports.txt | |
netstat -a -n -o | FIND "%PORT%" | |
IF NOT %ERRORLEVEL%==0 ( | |
ECHO Starting Jenkins slave server... | |
) ELSE ( | |
ECHO Jenkins slave server may already be running. | |
IF "%1"=="stop" ( | |
FOR /F "tokens=5 delims= " %%G IN ( ports.txt ) DO ( | |
IF NOT "%%G"=="0" ( | |
taskkill.exe /F /pid %%G | |
) ELSE ( | |
ECHO Can't kill a PID of 0. | |
) | |
) | |
) ELSE ( | |
ECHO Pass the ^"stop^" parameter to actually kill the server. | |
) | |
GOTO :CLEANUP | |
) | |
:: run slave NOT as a service but on demand | |
java.exe -jar jenkins.war --httpPort=%PORT% --httpListenAddress=0.0.0.0 | |
:CLEANUP | |
DEL /Q ports.txt | |
timeout 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment