Date post: | 06-May-2015 |
Category: |
Technology |
Upload: | roger-xia |
View: | 4,112 times |
Download: | 3 times |
Continuous Integration with Jenkins CI
Jan Riemann und Niklas Lochschmidt
2 08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann
Late Integration is… not good Can Lead to “Big Bang Integration”
Deliverable
Master
Integration
External Project
3
Integration
Deliverable
Continuous Integration
08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann
Master
External Project
§ A software development practice § Integrate your work in the project as often as possible § At least once a day § Integration goes alongside the development à continuous
§ Integration is no longer a dreadful (often postponed) event § Only possible through automated builds, tests and deployment § Leads to better quality and early deliverables
4
CI Best Practices
§ Maintain a single source repository § One team has one repository holding the mainline (trunk) § Checkout must include everything needed for the build
§ Automate the build § Use a script or a build tool (e.g. Maven) § Manage dependencies § Make the build fast § Show all warnings and errors § Fail early
08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann
5
CI Best Practices
§ Make your build self-testing § Run tests as part of the build process § Provide rapid feedback § define a test pipeline with distinct test phases
§ Test in the production clone
§ Automate deployment § Always publish the latest tested build § Everyone has the same state § Could go directly in production (not recommended)
à Automate the entire setup using 08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann
Integration Tests
Unit Tests Static Code Analysis
6
What is Jenkins CI?
§ Jenkins is a central build server § Written in Java § Runs as Servlet in Tomcat or standalone (e.g. Windows Service)
§ Performs „jobs“ § Configurable § Does all the tedious work (checkout, build, test, package, deploy)
§ Adapts to your workflow § More than 350 plugins available
§ Jenkins forked from Hudson (Oracle) in January 2011 § Most Hudson developers switched to Jenkins § Oracle donated Hudson to the Eclipse Foundation in May 2011
08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann
7
Repository Contains Everything Needed to Build the Project
§ CI: Repository contains: § Code, Resources § NO build products
§ Jenkins supports many common SCM systems like SVN, CVS § Automatic checkout/update on build § Build on updates in the SCM
08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann
8
Building the Project Relies on External Build Tools
§ Jenkins relies on external build tools § Many common tools supported -
like Ant, Maven, Ivy (plugins), … § Allows to reuse the build scripts
used locally
§ Jenkins builds the project… § after another project has been
builded § according to a given schedule § after code changes in the SCM § many other (=> Plugins)
08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann
9
Jenkins Allows to Perform Post-Build Actions
§ If build fails, Jenkins considers job as failed § Jenkins allows to perform a number of post-build actions:
08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann
10
Common Test-Frameworks are Supported by Jenkins
§ Jenkins can use all test frameworks supported by the build tool § Has plugins to read and visualize the test results of various frameworks § Junit, Checkstyle, Findbugs, Selenium, coverage tools,...
08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann
11
Multiple Test-Sets can be Executed using Jobs
§ Multiphase testing § Small tests can be executed after each SCM commit giving fast feedback § Time consuming tests can be executed on a nightly basis (e.g. Selenium FF) § One job for each set of tests
§ CI: Tests should also happen in a production system clone § Tests fail: Jenkins considers project as unstable § Otherwise: successfull
§ Keeps history of build status
08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann
12
Jenkins Supports Automatic Deployment
§ Jenkins offers (again) a lot of possibilities to deploy generated artifacts § Upload to scm, ftp, folder, …
§ Ideally, the output of a build cycle is a fully running artifact § Can serve as a common basis for all developers
08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann
13
Sources
§ Continuous Integration § http://martinfowler.com/articles/continuousIntegration.html § http://www.se-radio.net/?s=133
§ Jenkins § Homepage http://www.jenkins-ci.org § Wiki http://wiki.jenkins-ci.org § Plugin-List https://wiki.jenkins-ci.org/display/JENKINS/Plugins § Github https://github.com/jenkinsci/jenkins § Jenkins CI Server http://ci.jenkins-ci.org/ § Fork from Hudson http://jenkins-ci.org/content/hudsons-future
08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann
14
Get Notified about Failed Builds and Failed Tests
§ Via Email (Default) or...
08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann
... http://www.pragmaticautomation.com/cgi-bin/pragauto.cgi/Monitor/Devices/BubbleBubbleBuildsInTrouble.rdoc
15
Integration in Eclipse
§ „Mylyn Builds Connector: Hudson/Jenkins“ in the Mylyn repository § Update-Site: http://download.eclipse.org/mylyn/releases/latest
08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann
16
Jenkins Supports Multi-Environment Builds
§ Multi-environment builds § Easy to automatically build (and test) the project on many platforms using
slaves § Multiplatform testing § Jenkins slaves can execute the testsuite on different platforms
08. Juni 2011 | Component Technology for Distributed Applications | Niklas Lochschmidt, Jan Riemann