48
Hudson SF JUG Kohsuke Kawaguchi Sun Microsystems, Inc.

Learn About Continuous Integration With Hudson Directly From the Source

Embed Size (px)

DESCRIPTION

San Francisco Java User Group presents Kohsuke Kawaguchi from Sun who introduces us to Hudson, an open-source continuous integration (CI) system, which improves the productivity of a development team by automating various things. Hosted By: SUPINFO International University Sponsored By: TEKsystems, Sun, O'Reilly, JetBrains, and Marakana Organized By: Marakana Video By: Max Walker Video available at http://marakana.com/forums/java/general/79.html

Citation preview

Page 1: Learn About Continuous Integration With Hudson Directly From the Source

HudsonSF JUG

Kohsuke KawaguchiSun Microsystems, Inc.

Page 2: Learn About Continuous Integration With Hudson Directly From the Source

2

Rise of Continuous Integration

Offload from people, push to computers$

time

computers

people

Page 3: Learn About Continuous Integration With Hudson Directly From the Source

Spend more CPU power to help you

First on your laptops and workstations IDEs are at the forefront

And then to the servers a.k.a. “Continuous Integration” More frequent build/test executions Static code analysis tools And more to come

3

Page 4: Learn About Continuous Integration With Hudson Directly From the Source

Hudson

Open-source CI server Emphasis on ease of installation and use

“java -jar hudson.war” execution Or your OS-specific package Configure everything from browsers

Extensibility 230+ community-developed public plugins By 230+ contributors

Estimated 13,000 installations4

https://hudson-ci.org/

Page 5: Learn About Continuous Integration With Hudson Directly From the Source

Adoption in all kinds of businesses

5

Page 6: Learn About Continuous Integration With Hudson Directly From the Source

6

Support Subscriptions

Community releases every week Over 340 releases to date Rapid new features & bug fixes delivery

“Sun Continuous Integration Server” For enterprise that needs stability Bug fix only patch releases for 18

months

Page 7: Learn About Continuous Integration With Hudson Directly From the Source

Basic Feature Set

Hudson notices that there is a change Check out the source code

CVS, Subversion, ClearCase, Mercurial, Accurev, Perforce, Git, StarTeam, …

Do builds Ant, Maven, shell script, NAnt, …

Record and publish results Close the feedback loop

RSS feeds E-mail/IM notification Tray application to notify developers

Tool integration Findbugs, cobertura, …

7

Page 8: Learn About Continuous Integration With Hudson Directly From the Source

Demo

Page 9: Learn About Continuous Integration With Hudson Directly From the Source

9

Why do I care?

Life before Hudson Dev forgets to commit a file RE nightly build breaks. It blocks SQE People waste time

Life after Hudson Hudson will tell you in 5 mins if a build

broke No one else notices that you forgot to

commit a file

Page 10: Learn About Continuous Integration With Hudson Directly From the Source

10

Why do I care?

Life before Hudson Dev makes a change Monday AM SQE nightly finds a bug Monday night Dev fixes it Tuesday Lot of wasted time

Life after Hudson Dev makes a change Monday AM Hudson finds a regression 30 mins later Dev can fix it before lunch

Page 11: Learn About Continuous Integration With Hudson Directly From the Source

11

Why do I care?

Life before Hudson SQE test runs every night, results sent out

in e-mail After the enthusiasm of the 1st week is

gone, nobody looks at them anymore Regressions go unnoticed until it’s too late

Life after Hudson Tests run Hudson after every commit E-mail sent out only when tests start failing▪ So it manages to keep people’s attention

Page 12: Learn About Continuous Integration With Hudson Directly From the Source

Matrix projects

Run the same thing on different environments such as different

JDKs, different databases, and different OSes

Aggregate the results

12

Page 13: Learn About Continuous Integration With Hudson Directly From the Source

FindBugs integration

13

Page 14: Learn About Continuous Integration With Hudson Directly From the Source

14

Tracking changes

Page 15: Learn About Continuous Integration With Hudson Directly From the Source

… and more

BROWSE WORKSPACES

BUILD TIME TREND REPORT

15

Page 16: Learn About Continuous Integration With Hudson Directly From the Source

16

Inter-Project Support

You can host many projects on 1 Hudson And when you do, 1+1 becomes more

than 2 You can…

Execute tests separately and correlate them with builds

Mark builds as “promoted” based on test outcome

Track which build of libraries are used where

And more

Page 17: Learn About Continuous Integration With Hudson Directly From the Source

Test/Build Separation

Tests often dominate the build time Multiple tests are run in parallel

Improves turn-around time

JAX-WS #10

Unit test with GF

Unit test with Tomcat

SQE test

JAX-WS #11 JAX-WS #12 …

Test w/o container

3OS x 2JDK = 6 tests

time

17

Page 18: Learn About Continuous Integration With Hudson Directly From the Source

Test/Build Separation Technique

Copy bits from the build to test via wget by permalinks Ant has the equivalent <get> task

“Fingerprinting” to keep track of where binaries are used

$ wget –O foo.zip http://server/hudson/job/foo/lastSuccessfulBuild/ artifact/foo.zip

18

Page 19: Learn About Continuous Integration With Hudson Directly From the Source

19

Build Promotion

CI produces a lot of “successful” builds Often overwhelming to downstream

consumers

Run tests as fast as you can If a build passes tests, promote it

Page 20: Learn About Continuous Integration With Hudson Directly From the Source

20

Got the idea?

Automation Reduce turn-around time Make things transparent Remove people from the loop

Save people’s time Push jobs to servers, keep

workstations idle for you

Page 21: Learn About Continuous Integration With Hudson Directly From the Source

Doing Distributed Builds

21

Page 22: Learn About Continuous Integration With Hudson Directly From the Source

Why?

There’s only so much 1 computer can do

But lots of PCs = tedious What does Hudson do to help you?

22

Page 23: Learn About Continuous Integration With Hudson Directly From the Source

Installing new slaves

For first 20 or so slaves, we did it manually Insert CD, click, type, click, type, click, … But that doesn’t scale

Then we automated Available as “Hudson PXE Plugin”

23

Page 24: Learn About Continuous Integration With Hudson Directly From the Source

Automated System Installations

Slaves Power on, hit F12 PC boots from network

(PXE)

> Hudson + PXE plugin ISO images of OS

24

Page 25: Learn About Continuous Integration With Hudson Directly From the Source

Automated System Installations

Slaves Power on, hit F12 PC boots from network

(PXE) Choose OS from menu Installs non-interactively

> Hudson + PXE plugin ISO images of OS

Your corporate IT guy & his DHCP

server

25

Page 26: Learn About Continuous Integration With Hudson Directly From the Source

Distributed builds with Hudson

Master Serves HTTP requests Stores all important info

Slaves 170KB single JAR Assumed to be unreliable Scale to at least 100

Link Single bi-di byte stream No other requirements

Master

slave1

slave2

slave3

slave4

slave5

slave6

slave7

slave8

26

Page 27: Learn About Continuous Integration With Hudson Directly From the Source

How master and slaves start talking

For Unix slaves, via SSH Only need SSHD and JRE on slaves We just need a host name

27

Page 28: Learn About Continuous Integration With Hudson Directly From the Source

How master and slaves start talking

For Windows, DCOM We just need admin user name and

password No manual intervention Works even from Unix masters

28

Page 29: Learn About Continuous Integration With Hudson Directly From the Source

How master and slaves start talking

Via Java Web Start When master cannot see slaves A separate socket connection is made

29

Page 30: Learn About Continuous Integration With Hudson Directly From the Source

Automating JNLP launch

Once started, can be installed as Windows service

30

Page 31: Learn About Continuous Integration With Hudson Directly From the Source

Automating JNLP launch

Emulate the JNLP client headless

$ java -jar slave.jar -jnlpUrl URL

31

Page 32: Learn About Continuous Integration With Hudson Directly From the Source

Automated Tool Installation - JDK

JDK from http://java.sun.com/ Hudson automatically chooses the right

bundle Always up to date with new releases

32

Page 33: Learn About Continuous Integration With Hudson Directly From the Source

Automated Tool Installation - Apache

Ant and Maven from Apache

33

Page 34: Learn About Continuous Integration With Hudson Directly From the Source

Heterogeneous Cluster Challenge

Your builds/tests need to run in specific environment

Dependency on individual nodes hurts utilization

WombatWindows

test

Hudson Windows

test

Windows #1

jobs slaves

GlassFishWindows

test

Windows #2

Solaris#1

Hudson Solaris test

34

Page 35: Learn About Continuous Integration With Hudson Directly From the Source

Labels to rescue

Label is a group of slaves Tie jobs to labels

WombatWindows

test

Hudson Windows

test

Windows #1

jobs slaves

GlassFishWindows

test

Windows #2

Solaris#1

Hudson Solaris test

Windows

Solaris

Windows #3

35

Page 36: Learn About Continuous Integration With Hudson Directly From the Source

36

Concurrent Builds

time

Hudson #10

Hudson #11

Hudson #12

Hudson #13

Hudson #14

Hudson #15

Page 37: Learn About Continuous Integration With Hudson Directly From the Source

Forecasting failures

Hudson monitors key health metrics of slaves Low disk space, insufficient swap Clock out of sync Extensible

Slaves go offline automatically

38

Page 38: Learn About Continuous Integration With Hudson Directly From the Source

Clean up mess after builds

Kill run-away processes Daemons, background processes left by

your build Works on Windows, Linux, Mac, and

Solaris

39

Page 39: Learn About Continuous Integration With Hudson Directly From the Source

Load Statistics Monitoring

40

Page 40: Learn About Continuous Integration With Hudson Directly From the Source

When it’s time to add more slaves

41

Page 41: Learn About Continuous Integration With Hudson Directly From the Source

Hudson EC2 plugin

Automatically provisions slaves on EC2 on demand Based on the current load

Picks the right AMI depending on demand

Starts slave agent Shuts down unused instances

42

Page 42: Learn About Continuous Integration With Hudson Directly From the Source

Putting it all together

time

# o

f exe

cuto

rs

capacity

usagequeue length

43

Page 43: Learn About Continuous Integration With Hudson Directly From the Source

Hudson “Appliance” on EC2

Run the master in the cloud too, if you like Hudson on stock OpenSolaris AMI Data stored persistently in Elastic Block

Storage▪ Dynamically expandable thanks to ZFS▪ Online, too

Packaged as a wizard

44

Page 44: Learn About Continuous Integration With Hudson Directly From the Source

And a lot more I couldn’t show

IDE plugins iPhone/Android apps REST API and CLI Deployment Automation Hadoop, Selenium …

45

Page 45: Learn About Continuous Integration With Hudson Directly From the Source

Conclusions

CI is here to stay Using lots of PCs is a key

Hudson is very easy to get started Once started, there are a lot you can do

46

Page 46: Learn About Continuous Integration With Hudson Directly From the Source

Q&A

Kohsuke KawaguchiSun Microsystems, Inc.

Page 47: Learn About Continuous Integration With Hudson Directly From the Source

Compartmentalization

Faster feedback Good engineering practice anyway Isolation of problems

full Metro build #10 full Metro build #11

time

JAXB #10 JAXB #11 JAXB #12

JAX-WS #20 JAX-WS #21 JAX-WS #22

48

Page 48: Learn About Continuous Integration With Hudson Directly From the Source

Automated System Installations

Supports OpenSolaris, Ubuntu, CentOS, Fedora Trivial with most Linux

Cooperate with Windows, too

Quite useful outside Hudson, too No more broken CD drives No more CD-Rs

49