Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Jenkins without Install

3 731 vues

Publié le

Publié dans : Technologie
  • Login to see the comments

Jenkins without Install

  1. 1. Jenkins without Install
  2. 2. 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
  3. 3. 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
  4. 4. Preparation ● Putty Portable : To connect server ● Jenkins : Continuous Integration server ● Some xUnit – In this example, a unit test for shell shunit2 is used ● Passion!
  5. 5. 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
  6. 6. Putty Portable 2/2 Register key ● Copy public key to server – pscp id_rsa.pub yourname@mycompany.com: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 ~/.ssh chmod 700 ~/.ssh cd ~/.ssh ssh-keygen -i -f ~/id_rsa.pub >> authorized_keys chmod 600 authorized_keys rm ~/id_rsa.pub
  7. 7. Pagent ● Use Pagent to omit password for every use %PuTTYPortable%AppputtyPAGEANT.EXE "%HOMEDRIVE%%HOMEPATH%id_rsa.ppk" ● It may be good idea to put in startup
  8. 8. 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
  9. 9. Configure Jenkins 1/2 ● Launch Jenkins java -jar %Jenkins%jenkins.war ● Create new Job – Select free style
  10. 10. Configure Jenkins 2/2 ● Build / Add build step / Execute Windows batch command – PUTTY_PATH and RSA_FILE shall be modified to environment setlocal set PUTTY_PATH="D:PortableAppsPuTTYPortableAppputty" set USER=your_user set SERVER=some_server set 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%
  11. 11. Execute Job
  12. 12. View Result
  13. 13. Result 1/2 Success ● Success if all test pass
  14. 14. Result 2/2 Failure ● Failure if any test failed
  15. 15. 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

×