Jenkins and Groovy

5,523 views
5,366 views

Published on

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,523
On SlideShare
0
From Embeds
0
Number of Embeds
758
Actions
Shares
0
Downloads
31
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Jenkins and Groovy

    1. 1. Jenkins Groovy2011 2 26
    2. 2. (@kiy0taka id:kiy0taka) Grails/Groovy Jenkins Plugin Terminal jQuery jQuery UI LT Hudson http://www.ustream.tv/recorded/108018382011 2 26
    3. 3. Jenkins2011 2 26
    4. 4. 2011 2 26
    5. 5. Slide # 6 DevLOVE Groovy 2011.1.242011 2 26
    6. 6. import java.io.*; BufferedReader bis = new BufferedReader import java.net.*; (new InputStreamReader(ins)); String line; public class SocketAccess { while ((line = bis.readLine()) != null) { System.out.println(line); public static void main(String[] args) { } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); } } Slide # 7 DevLOVE Groovy 2011.1.242011 2 26
    7. 7. import java.io.*; BufferedReader bis = new BufferedReader import java.net.*; (new InputStreamReader(ins)); String line; public class SocketAccess { while ((line = bis.readLine()) != null) { System.out.println(line); public static void main(String[] args) { } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); } } Slide # 8 DevLOVE Groovy 2011.1.242011 2 26
    8. 8. import java.io.*; BufferedReader bis = new BufferedReader import java.net.*; (new InputStreamReader(ins)); String line; public class SocketAccess { while ((line = bis.readLine()) != null) { System.out.println(line); public static void main(String[] args) { } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); } } Slide # 8 DevLOVE Groovy 2011.1.242011 2 26
    9. 9. import java.io.*; BufferedReader bis = new BufferedReader import java.net.*; (new InputStreamReader(ins)); String line; public class SocketAccess { while ((line = bis.readLine()) != null) { System.out.println(line); public static void main(String[] args) { } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); } } Slide # 9 DevLOVE Groovy 2011.1.242011 2 26
    10. 10. import java.io.*; BufferedReader bis = new BufferedReader import java.net.*; (new InputStreamReader(ins)); String line; public class SocketAccess { while ((line = bis.readLine()) != null) { System.out.println(line); public static void main(String[] args) { } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); } } Slide # 9 DevLOVE Groovy 2011.1.242011 2 26
    11. 11. BufferedReader bis = new BufferedReader (new InputStreamReader(ins)); String line; public class SocketAccess { while ((line = bis.readLine()) != null) { System.out.println(line); public static void main(String[] args) { } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); } } Slide #10 DevLOVE Groovy 2011.1.242011 2 26
    12. 12. BufferedReader bis = new BufferedReader (new InputStreamReader(ins)); String line; public class SocketAccess { while ((line = bis.readLine()) != null) { System.out.println(line); public static void main(String[] args) { } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); } } Slide #10 DevLOVE Groovy 2011.1.242011 2 26
    13. 13. BufferedReader bis = new BufferedReader (new InputStreamReader(ins)); String line; while ((line = bis.readLine()) != null) { System.out.println(line); } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); Slide #11 DevLOVE Groovy 2011.1.242011 2 26
    14. 14. BufferedReader bis = new BufferedReader (new InputStreamReader(ins)); String line; while ((line = bis.readLine()) != null) { System.out.println(line); } Socket soc = null; } InputStream ins = null; catch (IOException e) { OutputStream outs = null; e.printStackTrace(); try { try { soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); } outs = soc.getOutputStream(); catch(IOException ex) {} outs.write("GET / HTTP/1.0nn".getBytes } ()); Slide #11 DevLOVE Groovy 2011.1.242011 2 26
    15. 15. BufferedReader bis = new BufferedReader (new InputStreamReader(ins)); String line; while ((line = bis.readLine()) != null) { System.out.println(line); } Socket soc = null; InputStream ins = null; OutputStream outs = null; soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); outs = soc.getOutputStream(); outs.write("GET / HTTP/1.0nn".getBytes ()); Slide #12 DevLOVE Groovy 2011.1.242011 2 26
    16. 16. BufferedReader bis = new BufferedReader (new InputStreamReader(ins)); String line; while ((line = bis.readLine()) != null) { System.out.println(line); } Socket soc = null; InputStream ins = null; OutputStream outs = null; soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); outs = soc.getOutputStream(); outs.write("GET / HTTP/1.0nn".getBytes ()); Slide #12 DevLOVE Groovy 2011.1.242011 2 26
    17. 17. bis = new BufferedReader(new InputStreamReader(ins)); def line = null; while ((line = bis.readLine()) != null) { System.out.println(line); } def soc = null; def ins = null; def outs = null; soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); outs = soc.getOutputStream(); outs.write("GET / HTTP/1.0nn".getBytes ()); Slide #13 DevLOVE Groovy 2011.1.242011 2 26
    18. 18. bis = new BufferedReader(new InputStreamReader(ins)); def line = null; while ((line = bis.readLine()) != null) { System.out.println(line); } def soc = null; def ins = null; def outs = null; soc = new Socket("www.java-users.jp", 80); if (soc != null) soc.close(); ins = soc.getInputStream(); outs = soc.getOutputStream(); outs.write("GET / HTTP/1.0nn".getBytes ()); Slide #13 DevLOVE Groovy 2011.1.242011 2 26
    19. 19. bis = new BufferedReader(new InputStreamReader(ins)); def line = null; while ((line = bis.readLine()) != null) { System.out.println(line); } } new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".getBytes ()); Slide #14 DevLOVE Groovy 2011.1.242011 2 26
    20. 20. bis = new BufferedReader(new InputStreamReader(ins)); def line = null; while ((line = bis.readLine()) != null) { System.out.println(line); } } new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".getBytes ()); Slide #14 DevLOVE Groovy 2011.1.242011 2 26
    21. 21. ins.eachLine{ line -> System.out.println(line); } } new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".getBytes ()); Slide #15 DevLOVE Groovy 2011.1.242011 2 26
    22. 22. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".getBytes()); ins.eachLine { line -> System.out.println(line); } } Slide #16 DevLOVE Groovy 2011.1.242011 2 26
    23. 23. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".getBytes()); ins.eachLine { line -> System.out.println(line); } } Slide #17 DevLOVE Groovy 2011.1.242011 2 26
    24. 24. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".getBytes()); ins.eachLine { line -> System.out.println(line); } } Slide #17 DevLOVE Groovy 2011.1.242011 2 26
    25. 25. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes); ins.eachLine { line -> System.out.println(line); } } Slide #18 DevLOVE Groovy 2011.1.242011 2 26
    26. 26. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes); ins.eachLine { line -> System.out.println(line); } } Slide #18 DevLOVE Groovy 2011.1.242011 2 26
    27. 27. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes); ins.eachLine { line -> println(line); } } Slide #19 DevLOVE Groovy 2011.1.242011 2 26
    28. 28. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes); ins.eachLine { line -> println(line); } } Slide #19 DevLOVE Groovy 2011.1.242011 2 26
    29. 29. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes); ins.eachLine { println(it); } } Slide #20 DevLOVE Groovy 2011.1.242011 2 26
    30. 30. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes); ins.eachLine { println(it); } } Slide #20 DevLOVE Groovy 2011.1.242011 2 26
    31. 31. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes) ins.eachLine { println(it) } } Slide #21 DevLOVE Groovy 2011.1.242011 2 26
    32. 32. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write("GET / HTTP/1.0nn".bytes) ins.eachLine { println(it) } } Slide #21 DevLOVE Groovy 2011.1.242011 2 26
    33. 33. new Socket("www.java-users.jp", 80).withStreams { ins, outs -> outs.write "GET / HTTP/1.0nn".bytes ins.eachLine { println it } } Slide #22 DevLOVE Groovy 2011.1.242011 2 26
    34. 34. println new URL("http://www.java-users.jp").text Slide #23 DevLOVE Groovy 2011.1.242011 2 26
    35. 35. Grape Maven/Ivy jar 22011 2 26
    36. 36. Grape @Grab(‘groupId:artifactId:version’) import groovy.grape.Grape Grape.grab(group:groupId, module:artifactId, version:version) grape install <groupId> <artifactId> <version>2011 2 26
    37. 37. @Grab ( ) @Grab(org.apache.poi:poi:3.2-FINAL) import org.apache.poi.hssf.usermodel.* def workBook = new HSSFWorkbook(new File(./foo.xls) workBook.newInputStream()).sheets.each { sheet -> sheet.firstRowNum.upto(sheet.lastRowNum) { sheet.getRow(it).with { row -> row.firstCellNum.upto(row.lastCellNum - 1) { println row.getCell(it).stringCellValue } } } }2011 2 26
    38. 38. @Grab ( ) @Grab(org.mortbay.jetty:jetty-embedded:6.1.25) @Grab(com.h2database:h2:1.2.144) @Grab(mysql:mysql-connector-java:5.1.13) import org.mortbay.jetty.Server import org.mortbay.jetty.servlet.Context import org.h2.server.web.WebServlet def server = new Server(8080) new Context(server, "/", Context.SESSIONS) .addServlet(WebServlet, "/*") server.start()2011 2 26
    39. 39. 2011 2 26
    40. 40. http://groovy.codehaus.org/Download $ unzip groovy-binary-1.7.8.zip -d $JENKINS_HOME/tools/ $ chmod -R +x /opt/groovy-1.7.8/ $ export GROOVY_HOME=/opt/groovy-1.7.8/ $ export PATH=$GROOVY_HOME/bin2011 2 26
    41. 41. groovysh2011 2 26
    42. 42. groovyConsole2011 2 26
    43. 43. �2011 2 26
    44. 44. Groovy Jenkins Groovy Jenkins Jenkins Groovy2011 2 26
    45. 45. Jenkins2011 2 26
    46. 46. Groovy $JENKINS_HOME/init.groovy http://jenkinsserver/script Jenkins CLI Groovy Jenkins groovysh Jenkins2011 2 26
    47. 47. init.groovy $JENKINS_HOME/init.groovy Post-initialization script import hudson.model.*; // start in the state that doesnt do any build. Hudson.instance.doQuietDown(); http://wiki.jenkins-ci.org/display/JENKINS/Post-initialization+script2011 2 26
    48. 48. Groovy Jenkins http://jenkinsserver/script2011 2 26
    49. 49. Jenkins CLI (Script) $ java -jar jenkins-cli.jar > -s http://jenkinsserver > groovy hoge.groovy http://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console http://scriptlerweb.appspot.com/2011 2 26
    50. 50. Jenkins CLI (groovysh) $ java -jar jenkins-cli.jar > -s http://jenkinsserver groovysh2011 2 26
    51. 51. ... Groovy groovysh2011 2 26
    52. 52. JenkinsGroovyConsole GroovyConsole Jenkins GroovyConsole jenkins-cli.jar groovy JenkinsGroovyConsole [jenkins_url] https://gist.github.com/8435072011 2 26
    53. 53. @GrabResolver(http://maven.glassfish.org/content/groups/public/) @Grab(org.jenkins-ci.main:cli:1.398) import hudson.cli.CLI import groovy.ui.Console jenkinsUrl = args ? args[0] : http://localhost:8080 Console.metaClass.newScript = { ClassLoader parent, Binding binding -> delegate.shell = new GroovyShell(parent, binding) delegate.shell.metaClass.run = { String scriptText, String fileName, List list -> def file = File.createTempFile(jenkinsgroovyconsole, .groovy) file.text = scriptText new CLI(jenkinsUrl.toURL()).execute([groovy, file.absolutePath], System.in, System.out, System.err) file.delete() null } } new Console(Console.class.classLoader.getRootLoader()).run()2011 2 26
    54. 54. Demo (JNLP) (SSH) -Dmven.test.skip=true2011 2 26
    55. 55. CI Groovy2011 2 26
    56. 56. Jenkins Groovy2011 2 26
    57. 57. 1. Groovy2011 2 26
    58. 58. 2. Groovy http://groovy.codehaus.org/Download $ unzip groovy-binary-1.7.8.zip -d $JENKINS_HOME/tools/ $ chmod -R +x $JENKINS_HOME/tools/groovy-1.7.8/2011 2 26
    59. 59. 3. Jenkins http://jenkinsserver/configure2011 2 26
    60. 60. Groovy Job2011 2 26
    61. 61. 2011 2 26
    62. 62. Commons VFS Jenkins IRC Bot2011 2 26
    63. 63. Groovy Grails/Groovy (JGGUG) http://www.jggug.org (?) G*Magazine http://grails.jp/g_mag_jp/2011 2 26
    64. 64. 2011 2 26

    ×