Your SlideShare is downloading. ×
Jenkins Scriptler in 90mins
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Jenkins Scriptler in 90mins

3,286
views

Published on

Learn Jenkins Scriptler in 90 minutes

Learn Jenkins Scriptler in 90 minutes

Published in: Technology

0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,286
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
44
Comments
0
Likes
10
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Larry cai <larry.caiyu@gmail.com>
  • 2. Agenda        What is Jenkins Scriptler ? Exercise 1: Hello World in Jenkins script console Exercise 2: Hook into Jenkins Exercise 3: Jenkins Java API Exercise 4: Find the needed Jenkins Java method Exercise 5: Put into Jenkins Scriptler Exercise 6: Learn more Groovy 2 Jenkins Scriptler in 90 minutes
  • 3. 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 https://wiki.jenkins-ci.org/display/JENKINS/Scriptler+Plugin  Use http://<jenkins job>/scriptler/ or Jenkins -> Scriptler (system menu) 3 Jenkins Scriptler in 90 minutes
  • 4. 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 4 Jenkins Scriptler in 90 minutes
  • 5. Exercise 1 – Hello World  Jenkins Console the place to exercise the Jenkins script https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console 5 Jenkins Scriptler in 90 minutes
  • 6. 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” 6 Jenkins Scriptler in 90 minutes
  • 7. 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 7 Jenkins Scriptler in 90 minutes
  • 8. 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 ;-)  8 Jenkins Scriptler in 90 minutes
  • 9. Exercise 5: Put into Jenkins Scriptler  Now put the scripts into Jenkins Scriptler Id & Name: geturl  Add parameter for “job_prefix”, use “$name”  9 Jenkins Scriptler in 90 minutes
  • 10. Exercise 6: learn more Groovy    Install Groovy Console http://groovy.codehaus.org/ Learn loop syntax http://groovy.codehaus.org/Looping List string in closures way 10 Jenkins Scriptler in 90 minutes
  • 11. Reference  Market place    Groovy   http://scriptlerweb.appspot.com/catalog/list https://github.com/jenkinsci/jenkins-scripts/tree/master/scriptler http://groovy.codehaus.org Small guideline  11 http://earlyandoften.wordpress.com/2013/03/11/masteringjenkins-making-bulk-updates-to-jobs/ Jenkins Scriptler in 90 minutes