35
Version Control and Continuous Integration THE STACKOVERFLOW MEETUP – CEBU MAY 26, 2012 emxsi

Version Control and Continuous Integration

Embed Size (px)

DESCRIPTION

This is Greg Montaño's slides on "Version Control and Continuous Integration", which was presented at the Cebu StackOverflow Meetup on 26 May 2012.

Citation preview

Page 1: Version Control and Continuous Integration

Version Control and Continuous Integration

THE STACKOVERFLOW MEETUP – CEBUMAY 26, 2012

emxsi

Page 2: Version Control and Continuous Integration

Introduction

• Batch, Pascal, PERL, Javascript, C++, JAVA

• DUNE2

• Shell Scripts• Modern Conflict

• University Faculty • Employee - IT Company

• I love to visit all the nearby islands of Cebu.

Page 3: Version Control and Continuous Integration

Expectations

• Introduce version control and CI• Focus only on Subversion and Jenkins• Discuss about installation and getting started

with these tools.• Sharing of personal experiences pertaining to

the tools mentioned is also encouraged during the Q&A.

Page 4: Version Control and Continuous Integration

Version Control

• Also known as revision control.

• According to http://www.smashingmagazine.com/ the most obvious benefit of revision control is– ability to have an unlimited number of people

working on the same code base, without having to constantly send files back and forth.

Page 5: Version Control and Continuous Integration

Models of Version Control Software

• Local data Model

• Client-Server Model

• Distributed Model

Page 6: Version Control and Continuous Integration

Version Control in the Market

• Proprietary– BitKeeper– PVCS– Synergy– Perforce– ClearCase– Visual SourceSafe– Rational Team Concert

Page 7: Version Control and Continuous Integration

Version Control in the Market

• Open Source– Concurrent Versions System (CVS)– Subversion (SVN)– Distributed Concurrent Versions System (DCVS)– Bazaar – Mercurial– Git

Page 8: Version Control and Continuous Integration

Subversion

• Triggered development by CollabNet, Inc in early 2000• Took 14 months to develop• Became part of ASF's family of top-level projects on

early 2010.

• Book titled Version Control with Subversion can be found and/or downloaded at

http://svnbook.red-bean.com/• Subversion current version is 1.7

Page 9: Version Control and Continuous Integration

SUBVERSION'S ARCHITECTURE

Page 10: Version Control and Continuous Integration

Subversion repository

Page 11: Version Control and Continuous Integration

Repository access URLs Schema Access method

file:/// Direct repository access (on local disk)

http:// Access via WebDAV protocol to Subversion-aware Apache server

https:// Same as http://, but with SSL encryption

svn:// Access via custom protocol to an svnserve server

svn+ssh:// Same as svn://, but through an SSH tunnel

Page 12: Version Control and Continuous Integration

5 steps to getting started (Version Control)

1. Download and install2. Create the repository3. Set-up authentication4. Customize (e.g. pre-commit hooks)5. Perform maintenance like backups

Page 13: Version Control and Continuous Integration

Create the repository

• Create the directorymkdir –p /var/www/svn

• Create the repocd /var/www/svnsvnadmin create myrepo

• Access the repo via httphttp://143.143.143.143/svn/myrepo

Page 14: Version Control and Continuous Integration

Content of subversion.conf

LoadModule dav_svn_module modules/mod_dav_svn.so

LoadModule authz_svn_module modules/mod_authz_svn.so

<Location /svn> DAV svn SVNParentPath /var/www/svn AuthType Basic AuthName "Subversion repositories" AuthUserFile /etc/httpd/svn-users.passwd Require valid-user</Location>

Page 15: Version Control and Continuous Integration

Structure of SVN Repository

• trunk - directory to hold the “main line” of development;

• branches - directory to contain branch copies;• tags - directory to contain tag copies;

Page 16: Version Control and Continuous Integration

Customize

• Use of hooks like pre-commit• The pre-commit hook is run just before a

commit transaction is promoted to a new revision.

• Useful for freezing a release and/or requiring for log messages before revisions are committed to the repository.

• /var/www/svn/myrepo/hooks/pre-commit

Page 17: Version Control and Continuous Integration

Backups

• Full backupsvnadmin hotcopy /var/www/svn/myrepo ~/repo-backuptar cjvhpf repo-backup.bz2 ~/repo-backup

• Incrementalsvnadmin dump /var/www/svn/myrepo –r 143:HEAD --

incremental > `date +%s`.dump

Page 18: Version Control and Continuous Integration

Subversion Best Practices

1. Use a sane repository layout2. Commit logical changesets3. Use the issue-tracker wisely4. Provide meaningful log message5. Know when to branch

Page 19: Version Control and Continuous Integration

Continuous Integration (CI)

• implements continuous processes of applying quality control — small pieces of effort, applied frequently.

• a set of software development practices, behaviors, and principles for automating and improving how to integrate and certify software continuously.

• Started around 1999

Page 20: Version Control and Continuous Integration

Why use CI?

• to deliver stable, high-quality code consistently and quickly;

• detect and fix problems early;• deliver quality software; • reduce time to market of the finish product;

Page 21: Version Control and Continuous Integration

0% interest

Buy Now Pay Later

Page 22: Version Control and Continuous Integration

Principles

• Maintain a Single Source Repository• Automate the Build• Make Your Build Self-Testing• Everyone Commits To the Mainline Every Day• Every Commit Should Build the Mainline on an Integration

Machine• Keep the Build Fast• Test in a Clone of the Production Environment• Make it Easy for Anyone to Get the Latest Executable• Everyone can see what's happening• Automate Deployment

Page 23: Version Control and Continuous Integration

CI in the Market

• Proprietary– Build Forge– AnthillPro– BuildMaster– TeamCity

Page 24: Version Control and Continuous Integration

CI in the Market

• OpenSource– CruiseControl– Jenkins/Hudson

Page 25: Version Control and Continuous Integration

4 steps to getting started (Jenkins)

1. Download and install2. Create and configure the project/job3. Run your first build4. Customize

Page 26: Version Control and Continuous Integration

http://jenkins-ci.org/

Page 27: Version Control and Continuous Integration

Configure Jenkins

Page 28: Version Control and Continuous Integration

New job/project

Page 29: Version Control and Continuous Integration
Page 30: Version Control and Continuous Integration
Page 31: Version Control and Continuous Integration

Plug-ins

• Over 400 plug-ins• Source code management (e.g. Git, Mercurial)• Artifact uploaders (e.g. Tomcat, JBOSS,

Websphere)• Build Reports (e.g. Cobertura, Sonar, Ruby)• Authentication and user management• UI Plugins

Page 32: Version Control and Continuous Integration

Reasons for CI

• Reports Any Build Failures to the Team• Reduces the Risk of Integrating Code

Private builds –> integration builds –> release builds

• Establishes Greater Confidence in the Product– Incorporated automated unit test in the build

• Improves the Efficiency of the Team

Page 33: Version Control and Continuous Integration

MAKE LIFE EASY FOR EVERYBODY

Page 34: Version Control and Continuous Integration

Salamat!

Page 35: Version Control and Continuous Integration

Reference:

• Internet