Continuous
Integration with
Node.js and Atlassian
Bamboo
Issac Goldstand
issac@itsgoodconsulting.com
ABOUT THE PRESENTOR

...
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 ...
Before we get ahead of ourselves...





Continuous Integration is a practice of
constantly merging source code, and
bu...
Powered By

Play @ Home
 Download

Git (http://git-scm.com/downloads)
 Download VirtualBox
(https://www.virtualbox.org/w...
Bring up the local environment
git clone --recursive https://github.com/issacg/mochademo.git
 EDIT mocha-demo/bamboo/attr...
Node.js and Mocha Support for Bamboo
 The

Node.js plugin is included in the VirtualBox image
 Bamboo Node.js plugin via...
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/moc...
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('/revers...
What if it fails?
$ cd /opt/demo/node
$ git checkout example2
$ npm test
> mocha-bamboo-demo@0.9.1 test /opt/demo/node
> n...
Bring up the local Bamboo server
 http://localhost:8085/
 Get

a free evaluation license (https://my.atlassian.com/licen...
Setting up Bamboo
 Create

a new Plan
 Source is Git (git@github.com:issacg/mocha-demo.git)
 Add tasks (all in “node” s...
Testing From
Bamboo




Default (build from
“master”) should pass –
green
Run  Customized to
run specific revision


...
Continuous Integration
 Use

triggers in Bamboo to
automate build




Polling Git repository
Push to Bamboo via Webhoo...
Part Three – (Continuous) Deployment
Deployment
 Deployment

options added since Bamboo 5
 Intuitive and informative UI + JIRA integration
 Build results ma...
Deploying via SCC tags
 Extremely

popular deployment

pattern
 … but Bamboo can’t mark a
“tag” as release, only an
Arti...
Deploying via artifact
 Especially

useful in compiled languages, or including runtime prerequisites (like npm packages)
...
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)

Artifac...
In the meantime…
 Hack


around it 

I recommend either external artifact store by uploading
artifacts at the end of a ...
To Summarize


Part One





Part Two





We learned about Continuous Integration and Continuous
Deployment princi...
Special Thanks…
That’s All, Folks!
Issac Goldstand
issac@itsgoodconsulting.com

Link To Slides

http://www.itsgoodconsulting.com/blog/issa...
Upcoming SlideShare
Loading in …5
×

Continuous Integration With Node.js and Bamboo

10,005 views

Published on

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.

Published in: Technology, Business
1 Comment
5 Likes
Statistics
Notes
  • I have written the API test cases into my repository using Frisby API framework. I want to implement the Bamboo server for CI integration to run the test cases after commit some code. So can you please guide something in which how to start the flow. Also we have Bamboo server and already created plan.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
10,005
On SlideShare
0
From Embeds
0
Number of Embeds
522
Actions
Shares
0
Downloads
1
Comments
1
Likes
5
Embeds 0
No embeds

No notes for slide

Continuous Integration With Node.js and Bamboo

  1. 1. Continuous Integration with Node.js and Atlassian Bamboo Issac Goldstand issac@itsgoodconsulting.com ABOUT THE PRESENTOR http://linkedin.com/in/margol
  2. 2. 60 seconds before we get started…
  3. 3. 60 seconds before we get started…
  4. 4. Part One – Introduction
  5. 5. 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?
  6. 6. 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
  7. 7. 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
  8. 8. 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
  9. 9. 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
  10. 10. Part Two – Continuous Integration
  11. 11. 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)
  12. 12. Don’t forget to run it! $ node index.js http://localhost:8080/reverse/hello elloh It’s ALIVE!!!
  13. 13. 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); }); });
  14. 14. 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
  15. 15. 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
  16. 16. 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
  17. 17. 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
  18. 18. 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…
  19. 19. Part Three – (Continuous) Deployment
  20. 20. 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 )
  21. 21. 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
  22. 22. 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
  23. 23. GIT Bamboo / Slave
  24. 24. GIT PULL Source Files Bamboo / Slave
  25. 25. GIT Source Files Artifact Bamboo / Slave
  26. 26. GIT External High-Availability Storage Artifact Bamboo / Slave
  27. 27. GIT External High-Availability Storage Artifact Artifact PULL Bamboo / Slave Production Cluster (Chef/Puppet)
  28. 28. GIT External High-Availability Storage PULL Artifact Artifact Bamboo / Slave Production Cluster (Chef/Puppet) Artifact
  29. 29. 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
  30. 30. 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
  31. 31. Special Thanks…
  32. 32. 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/

×