Jenkins without Install
-
Upload
hirokazu-tokuno -
Category
Technology
-
view
726 -
download
0
Transcript of Jenkins without Install
Jenkins without Install
About me
● TOKUNO, Hirokazu● IT system at Manufacturing site● 4th year since assigned to IT at age of 39
– Learning a lots to catch up
● Little experience
– VBA, Java, Perl, Shell...
● Love to minimize code
– Pentaho ETL, Mojolicious
Purpose
● Jenkins to manage automation test although no install allowed to server
● Pre-conditions
– No install on server
– Have Windows PC
– No install on Windows
– An account that can directory login and execute test
● Expected Results
– Trigger test from Jenkins and collect results
Preparation
● Putty Portable : To connect server● Jenkins : Continuous Integration server● Some xUnit
– In this example, a unit test for shell shunit2 is used
● Passion!
Putty Portable 1/2 Generate key
● PUTTYGEN to generate key– Run %PuTTYPortable%
¥App¥putty¥PUTTYGEN.EXE
– Click Generate
– Move mouse!!!!
● Save keys as id_rsa.ppk, id_rsa.pub for private key and publick key– Key passphrase
● Better to set a password for using key, not same as password to login server
Putty Portable 2/2 Register key
● Copy public key to server– pscp id_rsa.pub [email protected]:id_rsa.pub
– Type “Y” for first connection, following message shall be displayed.
– The server's host key is not cached in the registry.
~ some lines ~
Store key in cache? (y/n) ● Register public key on server
mkdir ~/.sshchmod 700 ~/.sshcd ~/.sshssh-keygen -i -f ~/id_rsa.pub >> authorized_keyschmod 600 authorized_keysrm ~/id_rsa.pub
Pagent
● Use Pagent to omit password for every use%PuTTYPortable%\App\putty\PAGEANT.EXE "%HOMEDRIVE%%HOMEPATH%\id_rsa.ppk"
● It may be good idea to put in startup
Shunit2
● Extract Shuni2 2.1– 2.0 does not result Jenkins to judge Success/Failure
– tar zxvf shunit2-2.1.6.tgz
~/Test/test_pass.sh
#! /bin/sh
testPass(){ assertEquals 1 1}
# load shunit2. ~/Test/shunit2
~/Test/test_mix.sh#! /bin/sh
testPass(){ assertEquals 1 1}
testFail(){ assetEquals 1 0}# load shunit2. ~/Test/shunit2
Configure Jenkins 1/2
● Launch Jenkins
java -jar %Jenkins%\jenkins.war
● Create new Job
– Select free style
Configure Jenkins 2/2
● Build / Add build step / Execute Windows batch command
– PUTTY_PATH and RSA_FILE shall be modified to environment
setlocalset PUTTY_PATH="D:\PortableApps\PuTTYPortable\App\putty\"set USER=your_userset SERVER=some_serverset RSA_FILE="%HOMEDRIVE%%HOMEPATH%\id_rsa.ppk"set SERVER_COMMAND=sh ~/Test/test_pass.sh%PUTTY_PATH%plink -batch -ssh -i %RSA_FILE% %USER%@%SERVER% %SERVER_COMMAND%
Execute Job
View Result
Result 1/2 Success
● Success if all test pass
Result 2/2 Failure
● Failure if any test failed
Conclusion
● Test can be executed from Jenkins without any installation
– Script on server can be kicked from local PC
● Jenkins can judge the results from shunit2 on server