Jenkins without Install

15
Jenkins without Install

Transcript of Jenkins without Install

Page 1: Jenkins without Install

Jenkins without Install

Page 2: 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

Page 3: Jenkins without Install

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

Page 4: Jenkins without Install

Preparation

● Putty Portable : To connect server● Jenkins : Continuous Integration server● Some xUnit

– In this example, a unit test for shell shunit2 is used

● Passion!

Page 5: Jenkins without Install

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

Page 6: Jenkins without Install

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

Page 7: Jenkins without Install

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

Page 8: Jenkins without Install

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

Page 9: Jenkins without Install

Configure Jenkins 1/2

● Launch Jenkins

java -jar %Jenkins%\jenkins.war

● Create new Job

– Select free style

Page 10: Jenkins without Install

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%

Page 11: Jenkins without Install

Execute Job

Page 12: Jenkins without Install

View Result

Page 13: Jenkins without Install

Result 1/2 Success

● Success if all test pass

Page 14: Jenkins without Install

Result 2/2 Failure

● Failure if any test failed

Page 15: Jenkins without Install

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