Upgrade to Pro — share decks privately, control downloads, hide ads and more …

90分钟:jenkins_scriptler

Zoom.Quiet
December 04, 2013

 90分钟:jenkins_scriptler

Larry cai

Zoom.Quiet

December 04, 2013
Tweet

More Decks by Zoom.Quiet

Other Decks in Programming

Transcript

  1. Agenda  What is Jenkins Scriptler ?  Exercise 1:

    Jenkins script console  Exercise 2: String, List via command line  Exercise 3: Groovy  Exercise 4: Learn how to use module json to dump data  Exercise 5: Generate online NASDAQ data using json Jenkins Scriptler in 90 minutes 2
  2. Jenkins Scriptler  Administering your jenkins scripts, which is used

    to trouble-shooting and diagnostics or routing tasks in jenkins  Provides a way to share scripts between users via hosted script catalogs on the internet.  Install plugin  Use http://<jenkins job>/scriptler/ or Jenkins -> Scriptler (system menu) Jenkins Scriptler in 90 minutes 3 https://wiki.jenkins-ci.org/display/JENKINS/Scriptler+Plugin
  3. Jenkins script  Jenkins script can access to Jenkins instance

    data and manipulate directly  Jenkins script use Groovy, which is an agile and dynamic language for the Java Virtual Machine  a.k.a java-like script language over JVM Jenkins Scriptler in 90 minutes 4
  4. Exercise 1 – Hello World  Jenkins Console the place

    to exercise the Jenkins script Jenkins Scriptler in 90 minutes 5 https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console
  5. Exercise 2 – Hook into Jenkins  Get the jenkins

    java instance ji = jenkins.model.Jenkins.instance  All the items (include jobs) jobs = ji.items  Printout the job names started with “test” Jenkins Scriptler in 90 minutes 6
  6. Exercise 3: Jenkins Java API  Script use jenkins JAVA

    API to access internal data http://javadoc.jenkins-ci.org/  Jenkins instance is http://javadoc.jenkins-ci.org/jenkins/model/Jenkins.html  Then locate “getAllItems()” API Jenkins Scriptler in 90 minutes 7
  7. Exercise 4 – Find the needed method  Find the

    Item API and try to printout the url for the jobs  If needed, check the source code if java developers https://github.com/jenkinsci/jenkins/blob/master/core/src/main/  Otherwise Check samples ;-) Jenkins Scriptler in 90 minutes 8
  8. Exercise 5: Put into Jenkins Scriptler  Now put the

    scripts into Jenkins Scriptler  Id & Name: geturl  Add parameter for “job_prefix”, use “$name” Jenkins Scriptler in 90 minutes 9
  9. Exercise 6: learn more Groovy  Install Groovy  Learn

    loop syntax Jenkins Scriptler in 90 minutes 10
  10. Reference  Market place  http://scriptlerweb.appspot.com/catalog/list  https://github.com/jenkinsci/jenkins-scripts/tree/master/scriptler  Groovy

     http://groovy.codehaus.org  Small guideline  http://earlyandoften.wordpress.com/2013/03/11/mastering-jenkins-m Jenkins Scriptler in 90 minutes 12