+ All Categories
Home > Documents > 17. 2. 2012, Developer conference,...

17. 2. 2012, Developer conference,...

Date post: 30-Sep-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
53
Continuous integration with Jenkins CI Vojt ˇ ech Jur´ anek JBoss - a division by Red Hat 17. 2. 2012, Developer conference, Brno Vojt ˇ ech Jur ´ anek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 1 / 38
Transcript
Page 1: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Continuous integration with Jenkins CI

Vojtech Juranek

JBoss - a division by Red Hat

17. 2. 2012, Developer conference, Brno

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 1 / 38

Page 2: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Outline

What continuous integration (CI) is and why it’s useful.

Show you, that CI with Jenkins is easy (Python and Ruby examples).

Show you, that CI can be even more easy.

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 2 / 38

Page 3: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Continuous integration

When you are developing a piece of code, you probably

compile the sources from time to time (if the code is compiled)

check the functionality (run tests)

If something fails (compilation, tests etc.) you start to look for a wrongcommit. . .

Is it better and more easy to try to find a mistake in one commit(several/several dozen changed lines of code) or many commits(hundreds/thousands changed lines)?

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 3 / 38

Page 4: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Continuous integration

When you are developing a piece of code, you probably

compile the sources from time to time (if the code is compiled)

check the functionality (run tests)

If something fails (compilation, tests etc.) you start to look for a wrongcommit. . .

Is it better and more easy to try to find a mistake in one commit(several/several dozen changed lines of code) or many commits(hundreds/thousands changed lines)?

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 3 / 38

Page 5: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Continuous integration

When you are developing a piece of code, you probably

compile the sources from time to time (if the code is compiled)

check the functionality (run tests)

If something fails (compilation, tests etc.) you start to look for a wrongcommit. . .

Is it better and more easy to try to find a mistake in one commit(several/several dozen changed lines of code) or many commits(hundreds/thousands changed lines)?

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 3 / 38

Page 6: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Continuous integration

Yup, as small change as possible is better!

Checking the status of the project very often (after each commit, if possible) isroughly what we call continuous integration.CI is necessary when you use agile development methodology, but veryuseful even if you use any other development methodology.

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 4 / 38

Page 7: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Advantages

Immediate feedback to any change.

Immediate overview of the status of your project - test results, testcoverage, performance etc. (helps with decisions, planning).

Complete history of the project (test results, build artifacts, etc.).

Can improve your workflow (e.g. gerrit integration).

Can be very easily extended to continuous deployment and eventuallycontinuous delivery.

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 5 / 38

Page 8: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Don’t I spend too much time by running compilation and checking the results?

No, let the computer work instead of you. Hopefully, you time is more valuablethan machine time:-)

Well, I can write some bash scripts which compile the code and run thetests. . .

Later on:I should also automate

. . . checkout from SVN/git . . .

. . . and setup some post commit hook to run it only after a commit . . .

. . . analysis of test results . . .

. . . some notification, to get alert only when something fails . . .

. . . and I can also . . .

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 6 / 38

Page 9: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Don’t I spend too much time by running compilation and checking the results?

No, let the computer work instead of you. Hopefully, you time is more valuablethan machine time:-)

Well, I can write some bash scripts which compile the code and run thetests. . .

Later on:I should also automate

. . . checkout from SVN/git . . .

. . . and setup some post commit hook to run it only after a commit . . .

. . . analysis of test results . . .

. . . some notification, to get alert only when something fails . . .

. . . and I can also . . .

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 6 / 38

Page 10: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Don’t I spend too much time by running compilation and checking the results?

No, let the computer work instead of you. Hopefully, you time is more valuablethan machine time:-)

Well, I can write some bash scripts which compile the code and run thetests. . .

Later on:I should also automate

. . . checkout from SVN/git . . .

. . . and setup some post commit hook to run it only after a commit . . .

. . . analysis of test results . . .

. . . some notification, to get alert only when something fails . . .

. . . and I can also . . .

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 6 / 38

Page 11: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Don’t I spend too much time by running compilation and checking the results?

No, let the computer work instead of you. Hopefully, you time is more valuablethan machine time:-)

Well, I can write some bash scripts which compile the code and run thetests. . .

Later on:I should also automate

. . . checkout from SVN/git . . .

. . . and setup some post commit hook to run it only after a commit . . .

. . . analysis of test results . . .

. . . some notification, to get alert only when something fails . . .

. . . and I can also . . .

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 6 / 38

Page 12: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Don’t I spend too much time by running compilation and checking the results?

No, let the computer work instead of you. Hopefully, you time is more valuablethan machine time:-)

Well, I can write some bash scripts which compile the code and run thetests. . .

Later on:I should also automate

. . . checkout from SVN/git . . .

. . . and setup some post commit hook to run it only after a commit . . .

. . . analysis of test results . . .

. . . some notification, to get alert only when something fails . . .

. . . and I can also . . .

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 6 / 38

Page 13: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Don’t I spend too much time by running compilation and checking the results?

No, let the computer work instead of you. Hopefully, you time is more valuablethan machine time:-)

Well, I can write some bash scripts which compile the code and run thetests. . .

Later on:I should also automate

. . . checkout from SVN/git . . .

. . . and setup some post commit hook to run it only after a commit . . .

. . . analysis of test results . . .

. . . some notification, to get alert only when something fails . . .

. . . and I can also . . .

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 6 / 38

Page 14: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Don’t I spend too much time by running compilation and checking the results?

No, let the computer work instead of you. Hopefully, you time is more valuablethan machine time:-)

Well, I can write some bash scripts which compile the code and run thetests. . .

Later on:I should also automate

. . . checkout from SVN/git . . .

. . . and setup some post commit hook to run it only after a commit . . .

. . . analysis of test results . . .

. . . some notification, to get alert only when something fails . . .

. . . and I can also . . .

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 6 / 38

Page 15: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Don’t I spend too much time by running compilation and checking the results?

No, let the computer work instead of you. Hopefully, you time is more valuablethan machine time:-)

Well, I can write some bash scripts which compile the code and run thetests. . .

Later on:I should also automate

. . . checkout from SVN/git . . .

. . . and setup some post commit hook to run it only after a commit . . .

. . . analysis of test results . . .

. . . some notification, to get alert only when something fails . . .

. . . and I can also . . .

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 6 / 38

Page 16: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

. . . wait, don’t I re-invent the wheel??

Yes, you do! There are several good CI servers. And probably the mostpopular is Jenkins.

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 7 / 38

Page 17: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Jenkins

Kohsuke Kawaguchi started Hudson project in 2006 while working in Sun.Trademark and other issues after acquisition of Sun by Oracle.Community decided to rename Hudson to Jenkins in January 2011(Hudson is still developed by Oracle and Sonatype, now moving underEclipse foundation).Jenkins now affiliated with Software in the Public Interest (SPI) NPOAll important information can be found athttps://wiki.jenkins-ci.org/display/JENKINS/Governa nce+Document

Jenkins usage grows steeply -more then 30k instances inanonymous usage statistics (i.e.actual # of instances is probablyhigher as not all instances sendthe stats.)

670+ repositories and 350developer on GitHub!

year/month

2008

/12

2009

/02

2009

/04

2009

/06

2009

/08

2009

/10

2009

/12

2010

/02

2010

/04

2010

/06

2010

/08

2010

/10

2010

/12

2011

/02

2011

/04

2011

/06

2011

/08

2011

/06

2011

/08

2011

/10

2011

/12

# o

f in

stan

ces

0

5000

10000

15000

20000

25000

30000

35000

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 8 / 38

Page 18: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Jenkins

Kohsuke Kawaguchi started Hudson project in 2006 while working in Sun.Trademark and other issues after acquisition of Sun by Oracle.Community decided to rename Hudson to Jenkins in January 2011(Hudson is still developed by Oracle and Sonatype, now moving underEclipse foundation).Jenkins now affiliated with Software in the Public Interest (SPI) NPOAll important information can be found athttps://wiki.jenkins-ci.org/display/JENKINS/Governa nce+Document

Jenkins usage grows steeply -more then 30k instances inanonymous usage statistics (i.e.actual # of instances is probablyhigher as not all instances sendthe stats.)

670+ repositories and 350developer on GitHub!

year/month

2008

/12

2009

/02

2009

/04

2009

/06

2009

/08

2009

/10

2009

/12

2010

/02

2010

/04

2010

/06

2010

/08

2010

/10

2010

/12

2011

/02

2011

/04

2011

/06

2011

/08

2011

/06

2011

/08

2011

/10

2011

/12

# o

f in

stan

ces

0

5000

10000

15000

20000

25000

30000

35000

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 8 / 38

Page 19: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Releases, packages

http://jenkins-ci.org

Release cycle:

Released usually weekly - release early,release often.

Long term support (LTS) release - every3 months, every month minor releasewith backports of major bug fixes.

Distribution (Jenkins is a Java servlet):

Web archive (WAR).

Native package.

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 9 / 38

Page 20: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Running Jenkins

Download war file,deploy it on your favorite servlet container like JBoss AS 7 or Tomcat,or just simply run java -jar jenkins.war .

Install native package e.g. via yum and start it as a servicewget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenki ns-ci.org/redhat/jenkins.reporpm --import http://pkg.jenkins-ci.org/redhat/jenkins -ci.org.keyyum -y install jenkinsservice jenkins start

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 10 / 38

Page 21: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Installing plug-ins

Plug-ins are one of the strong point of Jenkins, around 400 plug-ins, plug-insfor almost everything.Visit Manage Jenkins -> Manage Plugins -> Available , see alsohttps://wiki.jenkins-ci.org/display/JENKINS/PluginsFew tips for language agnostic plugins:

SCM:CVS and Subversion are already pre-installed.Git plugin - integrates Jenkins with git.GitHub plugin - better integration with GitHub, e.g. browse changelog onGitHub etc.Plugins for most of the SCMs are available.

Issue tracker integration:Jira plugin.Bugzilla plugin.

Ingratiation with other tools / services:EC2 / Delta cloud plugins - using machines from cloud for builds.Gerrit plugin.

Notifications / post-build actions - almost whatever you like :-)

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 11 / 38

Page 22: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Few tips for language specific plug-ins

Java is very well supported, plugins for all commonly used tools.C++:

xUnit plugins - supports (besides other) UnitTest++, CppUnit, Boost TestLibraryqmakebuilder plugin

Python:Python pluginShining Panda plugin

Ruby:Ruby pluginRake pluginRuby metrics plugin

PHP:Check http://jenkins-php.org/ orbook PHP projects with Jenkins byO’Reilly

Far not a complete list, list above is just mypersonal selection of some interestingplugins! Also plugins for other languagesexists.

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 12 / 38

Page 23: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Few tips for language specific plug-ins

Java is very well supported, plugins for all commonly used tools.C++:

xUnit plugins - supports (besides other) UnitTest++, CppUnit, Boost TestLibraryqmakebuilder plugin

Python:Python pluginShining Panda plugin

Ruby:Ruby pluginRake pluginRuby metrics plugin

PHP:Check http://jenkins-php.org/ orbook PHP projects with Jenkins byO’Reilly

Far not a complete list, list above is just mypersonal selection of some interestingplugins! Also plugins for other languagesexists.

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 12 / 38

Page 24: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Few tips for language specific plug-ins

Java is very well supported, plugins for all commonly used tools.C++:

xUnit plugins - supports (besides other) UnitTest++, CppUnit, Boost TestLibraryqmakebuilder plugin

Python:Python pluginShining Panda plugin

Ruby:Ruby pluginRake pluginRuby metrics plugin

PHP:Check http://jenkins-php.org/ orbook PHP projects with Jenkins byO’Reilly

Far not a complete list, list above is just mypersonal selection of some interestingplugins! Also plugins for other languagesexists.

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 12 / 38

Page 25: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Few tips for language specific plug-ins

Java is very well supported, plugins for all commonly used tools.C++:

xUnit plugins - supports (besides other) UnitTest++, CppUnit, Boost TestLibraryqmakebuilder plugin

Python:Python pluginShining Panda plugin

Ruby:Ruby pluginRake pluginRuby metrics plugin

PHP:Check http://jenkins-php.org/ orbook PHP projects with Jenkins byO’Reilly

Far not a complete list, list above is just mypersonal selection of some interestingplugins! Also plugins for other languagesexists.

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 12 / 38

Page 26: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Few tips for language specific plug-ins

Java is very well supported, plugins for all commonly used tools.C++:

xUnit plugins - supports (besides other) UnitTest++, CppUnit, Boost TestLibraryqmakebuilder plugin

Python:Python pluginShining Panda plugin

Ruby:Ruby pluginRake pluginRuby metrics plugin

PHP:Check http://jenkins-php.org/ orbook PHP projects with Jenkins byO’Reilly

Far not a complete list, list above is just mypersonal selection of some interestingplugins! Also plugins for other languagesexists.

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 12 / 38

Page 27: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Few tips for language specific plug-ins

Java is very well supported, plugins for all commonly used tools.C++:

xUnit plugins - supports (besides other) UnitTest++, CppUnit, Boost TestLibraryqmakebuilder plugin

Python:Python pluginShining Panda plugin

Ruby:Ruby pluginRake pluginRuby metrics plugin

PHP:Check http://jenkins-php.org/ orbook PHP projects with Jenkins byO’Reilly

Far not a complete list, list above is just mypersonal selection of some interestingplugins! Also plugins for other languagesexists.

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 12 / 38

Page 28: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Plug-ins roadmap

Java plugins more mature, e.g. most Java tools plugins has auto-installer- if the tool is not installed, plugin is able to install and set it up (veryuseful when running in the cloud), such features in plug-ins for otherlanguages (Python, Ruby) will hopefully follow.

Moving Java specific features into the plug-ins.

Some originally Java features can be used also for other languages, e.g.JUnit test results can be used for any JUnit compatible format (seeexamples), JavaDoc can publish arbitrary documentation etc.

If you are missing something, you can always use shell task to executecommand you want . . .

. . . or implement missing plugin/functionality.Support for other languages - not only plug-ins for different languages buteven possibility to develop plugin in different languages! Already donefor Ruby, support for other languages should follow.

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 13 / 38

Page 29: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Python example: IPython

Fresh Fedora 16 installation

# Install Javayum -y install java-1.6.0-openjdk-devel

# Python setupyum -y install python-pip python-nose python-zmq python-v irtualenvpip-python install nose-cov

# Install Jenkinswget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenki ns-ci.org/redhat/jenkins.reporpm --import http://pkg.jenkins-ci.org/redhat/jenkins -ci.org.keyyum -y install jenkinsservice jenkins start

Via Jenkins UI install Git, Cobertura and ShiningPanda plug-ins.

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 14 / 38

Page 30: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Setup git repository:

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 15 / 38

Page 31: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Optionally set up repository browser if you want to browse commits directly onGitHub:

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 16 / 38

Page 32: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Add a build step: execute shellcommand (install tools, ipython andrun tests) in virtualenv:

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 17 / 38

Page 33: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Setup paths to unit and coverage reports:

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 18 / 38

Page 34: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Run a build and check the results:

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 19 / 38

Page 35: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Unit test results

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 20 / 38

Page 36: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

...and eventually easily check failed tests:

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 21 / 38

Page 37: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Test coverage report:

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 22 / 38

Page 38: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Ruby example: Rails tutorial blog project

# Install Ruby and Railsyum -y install ruby ruby-devel rubygems sqlite sqli-devel j sgem install railsgem install ci_reporter

# Create tutorial apprails new blograils generate scaffold Post name:string title:string con tent:text

Add into Rakefile

require ’rubygems’require ’ci/reporter/rake/test_unit’

Push your new app into git repo.Via Jenkins UI install Ruby metrics plugin (Rake plugin will be installed asdependency).

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 23 / 38

Page 39: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Add build step: execute Rake tasks(db migration, test setup and testexecution):

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 24 / 38

Page 40: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Setup path to unit test results and also you can turn on generation of Railsreports (annotations and statistics):

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 25 / 38

Page 41: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Run a build and check the results:

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 26 / 38

Page 42: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Unit tests results and Rails annotations report

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 27 / 38

Page 43: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Rails statistics report

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 28 / 38

Page 44: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Only basic examples.

Real use cases can be much more sophisticated. Jenkins has manyadvanced interesting features which allows you to create very robustbuilds.

Check Jenkins: The Definitive Guidehttp://www.wakaleo.com/books/jenkins-the-definitive -guide

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 29 / 38

Page 45: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Still not persuaded?

Don’t want to setup a build machine for Jenkins server/builds (or slowdown you dev machine)?

Still think it’s too difficult to setup CI?

Just lazy to do the setup?

Java hater (Java never ever on my server )?

<Any other reason>?

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 30 / 38

Page 46: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

OpenShift

. . . then consider some cloud PaaS (platform as a service) offering,e.g. OpenShift by Red Hat!

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 31 / 38

Page 47: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

OpenShift

https://openshift.redhat.com

Still some initial set up (like registration) needs to be done, but you needn’t

find suitable machine for Jenkins server

set up Jenkins server and build environment

maintain CI environment

Support for

Java

PHP

Python

Ruby

Perl

... and all this is for free! (in case of OpenShift Express)

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 32 / 38

Page 48: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Setup OpenShift app

Install OpenShift tools:

wget https://openshift.redhat.com/app/repo/openshift .repo-O /etc/yum.repos.d/openshift.repo

yum -y install rhc

If you don’t use yum, check OpenShift tutorial how to install it using gem.Register your domain:

rhc-create-domain -n mydomain -l rhlogin

Create your app with Jenkins CI enabled:rhc-create-app -a jbosstest -t jbossas-7.0 --enable-jenk ins ci

rhc-create-app -a rubytest -t ruby-1.8 --enable-jenkins c i

rhc-create-app -a pythontest -t python-2.6 --enable-jenk ins ci

Add existing app under Jenkins CI by

rhc-ctl-app -a myapp -e add-jenkins-client-1.4

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 33 / 38

Page 49: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

What OpenShift does

OpenShift will

create git repo for your application,

create Jenkins instance it already doesn’t exists,

create CI job for your app and do some basic setup,

after each commit run CI build,

deploy your application.

You have admin login for your Jenkins instance so you can install arbitraryplugin and modify jobs as in examples above.

See also video tutorial onhttps://openshift.redhat.com/app/express .Some OpenShift example apps: https://github.com/openshift .

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 34 / 38

Page 50: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Sample output

After each commit OpenShift starts CI builds

vjuranek@localhost rubytest\$ git pushEnter passphrase for key ’/home/vjuranek/.ssh/libra_id_ rsa’:Counting objects: 133, done.Delta compression using up to 2 threads.Compressing objects: 100\% (89/89), done.Writing objects: 100\% (124/124), 90.96 KiB, done.Total 124 (delta 20), reused 120 (delta 18)remote: Executing Jenkins build.remote:remote: You can track your build at http://ci-vjuranek.rhc loud.com/job/rubytest-buildremote:remote: Waiting for build to schedule....Doneremote: Waiting for job to complete.......Doneremote: SUCCESSremote: New build has been deployed.To ssh://fef2974bd2e1403f92f873358cf360c5@rubytest2- vjuranek.rhcloud.com/˜/git/rubytest2.git/

8e4a040..3fb2bd3 master -> master

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 35 / 38

Page 51: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Other PaaS offerings providing Jenkins

CloudBeeshttp://www.cloudbees.com/For FOSS projects free 2,000 minutes/month ofm1.small and 500/month minutes of m1.large build/testcapacityFor more details checkhttp://www.cloudbees.com/foss/index.cbExamples (FOSS projects):http://www.cloudbees.com/foss/foss-projects.cb

Shining Pandahttps://www.shiningpanda.comFor FOSS projects free 1 hour/dayFor more details checkhttps://www.shiningpanda.com/pricingExamples (FOSS projects):https://www.shiningpanda.com/public

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 36 / 38

Page 52: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Other (possibly) interesting stuff

Mobile Jenkinshttp://www.jenkins-ci.mobi/

Integration with Eclipsehttp://www.cloudbees.com/eclipse-plugin.cbhttp://tasktop.com/connectors/hudson-jenkins

KDE tray apphttps://gitorious.org/fargies-misc-tools/jenkins-tr ay

Python APIhttp://packages.python.org/python-jenkins

Ruby APIhttps://github.com/cowboyd/jenkins.rb

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 37 / 38

Page 53: 17. 2. 2012, Developer conference, Brnorvokal.fedorapeople.org/devconf2012/vjuranek-JenkinsCI.pdf · 2012, Developer conference, Brno Vojtech Jurˇ ´anek (Red Hat) Continuous integration

Want to know more about Jenkins?

Something unclear? Doesn’t work? Need some help with setup CI for yourproject?Room B411, tomorrow 12:45-13:15, I’ll be there for tomorrow and we candiscuss your issues.

Jenkins channels:

Mailing users lists:http://groups.google.com/group/jenkinsci-users

Mailing dev list:http://groups.google.com/group/jenkinsci-dev

IRC channel: #jenkins on http://www.freenode.net/

Twitter: http://twitter.com/jenkinsci

Interested in Jenkins and also virtualization? RHEV team is searchingJenkins specials!Check https://careers.redhat.com/ in near future.

Vojtech Juranek (Red Hat) Continuous integration with Jenkins CI 17. 2. 2012, Developer conference, Brno 38 / 38


Recommended