• Save
Continuous Integration With Node.js and Bamboo
Upcoming SlideShare
Loading in...5
×
 

Continuous Integration With Node.js and Bamboo

on

  • 2,316 views

Node’s a great language for web-applications that deal with a lot of I/O (like API-driven stuff) and earlier in the year I wrote some glue to Mocha and Atlassian Bamboo to let the latter collect ...

Node’s a great language for web-applications that deal with a lot of I/O (like API-driven stuff) and earlier in the year I wrote some glue to Mocha and Atlassian Bamboo to let the latter collect test reports from the former. There are hints to Chef, Vagrant and CD goodness inside, too, so you can actually set up the same platform I’m presenting on to follow along with from home.

Statistics

Views

Total Views
2,316
Views on SlideShare
2,173
Embed Views
143

Actions

Likes
0
Downloads
1
Comments
0

1 Embed 143

http://www.itsgoodconsulting.com 143

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Continuous Integration With Node.js and Bamboo Continuous Integration With Node.js and Bamboo Presentation Transcript

    • Continuous Integration with Node.js and Atlassian Bamboo Issac Goldstand issac@itsgoodconsulting.com ABOUT THE PRESENTOR http://linkedin.com/in/margol
    • 60 seconds before we get started…
    • 60 seconds before we get started…
    • Part One – Introduction
    • The Basics…  We have a project, with tests (regression, unit, behavioral – up to you)  Written in Node.js, tested with Mocha  We’d love to get Bamboo CI working  Now what?
    • Before we get ahead of ourselves...    Continuous Integration is a practice of constantly merging source code, and building and testing the result as often as possible (and useful) Originally part of XP (Extreme Programming) principles Lately has extended to Continuous Deployment – the practice of constantly deploying the latest builds to a customer / production environment Atlassian Bamboo was originally designed for CI, and recently extended to include CD features
    • Powered By Play @ Home  Download Git (http://git-scm.com/downloads)  Download VirtualBox (https://www.virtualbox.org/wiki/Downloads)  Download Vagrant (http://downloads.vagrantup.com/)  Install vagrant plugins   vagrant plugin install vagrant-berkshelf vagrant plugin install vagrant-omnibus
    • Bring up the local environment git clone --recursive https://github.com/issacg/mochademo.git  EDIT mocha-demo/bamboo/attributes/oracle.rb (change FALSE to TRUE to accept Oracle’s license)  cd mocha-demo  vagrant up (This will take a while)  cd bamboo*  vagrant up* (This will take a while) How cool was that?     *The final command will no longer be necessary in an upcoming release of vagrant-berkshelf
    • Node.js and Mocha Support for Bamboo  The Node.js plugin is included in the VirtualBox image  Bamboo Node.js plugin via Atlassian Marketplace / UPM  You’ll also need the Mocha reporter via npm package mocha-bamboo-reporter  Instructions at https://github.com/issacg/mochabamboo
    • Part Two – Continuous Integration
    • Testing from node $ git checkout example3 $ npm test > mocha-bamboo-demo@0.9.1 test /opt/demo/node > node node_modules/mocha/bin/mocha . 1 passing (97 ms)
    • Don’t forget to run it! $ node index.js http://localhost:8080/reverse/hello elloh It’s ALIVE!!!
    • The Test describe('GET /reverse', function() { it('should reverse the string', function(done) { request(app). get('/reverse/hello'). expect('Content-Type', 'text/plain'). expect(200, 'olleh', done); }); });
    • What if it fails? $ cd /opt/demo/node $ git checkout example2 $ npm test > mocha-bamboo-demo@0.9.1 test /opt/demo/node > node node_modules/mocha/bin/mocha 0 passing (28 ms) 1 failing 1) Reverser GET /reverse should reverse the string: Uncaught TypeError: Object #<IncomingMessage> has no method 'get‘ … npm ERR! weird error 1 npm ERR! not ok code 0
    • Bring up the local Bamboo server  http://localhost:8085/  Get a free evaluation license (https://my.atlassian.com/license/evaluation)  Use custom setup  Use external (MySQL 5.x) database  User bamboo, password bamboo  Create a new bamboo home  Set your initial user
    • Setting up Bamboo  Create a new Plan  Source is Git (git@github.com:issacg/mocha-demo.git)  Add tasks (all in “node” subdirectory)    Add NPM task “install” Add NPM task “run-script bamboo” Add Mocha tests collector task as Final Task
    • Testing From Bamboo   Default (build from “master”) should pass – green Run  Customized to run specific revision    “example1” will have no failed tests – syntax error in logs “example2” will have one failed test “example3” should pass all tests
    • Continuous Integration  Use triggers in Bamboo to automate build    Polling Git repository Push to Bamboo via Webhook Timed (Daily build)  Use (successful) builds (tests) to trigger deployments…
    • Part Three – (Continuous) Deployment
    • Deployment  Deployment options added since Bamboo 5  Intuitive and informative UI + JIRA integration  Build results marked as a “release” and “release” marked as deployed in one or more environments  Also possible to mark a release (one mark) as Approved or Rejected  Integrated with permissions system – give your developers control (or at least make them think they have it )
    • Deploying via SCC tags  Extremely popular deployment pattern  … but Bamboo can’t mark a “tag” as release, only an Artifact…  … and your Git repository needs to be firewall-accessible
    • Deploying via artifact  Especially useful in compiled languages, or including runtime prerequisites (like npm packages)    Artifact Push – Supported by Bamboo, including firewall transversal, but requires the target machine to have a Remote Agent license Artifact Pull – Supported by popular deployment tools (Chef, Puppet, Capistrano) but requires Firewall access and file access (FTP, HTTP) to Bamboo’s artifact store External artifact store – No native Bamboo support. Vote for it at https://jira.atlassian.com/browse/BAM-11876
    • GIT Bamboo / Slave
    • GIT PULL Source Files Bamboo / Slave
    • GIT Source Files Artifact Bamboo / Slave
    • GIT External High-Availability Storage Artifact Bamboo / Slave
    • GIT External High-Availability Storage Artifact Artifact PULL Bamboo / Slave Production Cluster (Chef/Puppet)
    • GIT External High-Availability Storage PULL Artifact Artifact Bamboo / Slave Production Cluster (Chef/Puppet) Artifact
    • In the meantime…  Hack  around it  I recommend either external artifact store by uploading artifacts at the end of a build  OR  Tagging SCC at the end of a build and using the tag in deployment scripts
    • To Summarize  Part One    Part Two    We learned about Continuous Integration and Continuous Deployment principles We saw how to set up a local environment to try all the examples here (and peek at the source code where applicable) We were able to run the Mocha unit tests from the command line We integrated Bamboo and a Git repository, and had Bamboo run the unit tests and show us the results Part Three  We touched on Deployment with Bamboo and saw how to do it today, and how it will (hopefully) be streamlined in the future
    • Special Thanks…
    • That’s All, Folks! Issac Goldstand issac@itsgoodconsulting.com Link To Slides http://www.itsgoodconsulting.com/blog/issac-presenting-continuous-integration-with-node-js-and-atlassian-bamboo/