RUN@cloud » Continuous Deployment (Automated) from DEV@cloud to RUN@cloud

Continuous Deployment (Automated) from DEV@cloud to RUN@cloud

Last modified by Michael Neale on 2011/07/21 00:22

Continuous deployment is all the rage. This tutorial will help you get started down that path. 

  • What we will use: maven (could be any build tool) and github for the repository (could also be anything - as long as it can be reached from the Jenkins build service to access the source code).
  • What we will end up with: push your code - your tests run, your code is deployed if it passes, you go have a celebratory beverage.

Tip: you can adapt most of this to deploy to something like Google App Engine (instead of CloudBees), or, if you have a lot of time on your hands (and money), Amazon BeanStalk. 

Step 1: create a maven webapp project, using the maven archetype command:

mvn archetype:create -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=example.myapp -DartifactId=myapp
 

Note you can read more about maven and cloudbees here

Open your pom.xml file and add in the plugin repository, and the cloudbees build plugin.

Step 2: test your deploy locally before you push it to the cloud. You will need your api key and secret:

mvn bees:deploy -Dbees.appid=youraccount/yourappname -Dbees.apikey=<key> -Dbees.secret=<secret>

This should deploy your app to the cloud (create a new app if it doesn't already exist).

Step 3: Create a repository in github - and follow the instructions to add your recently created project to it.

You don't have to use github - your own git repository, or SVN etc can work. 

Step 4: Create a new Jenkins Job in your DEV@cloud service to build your project

http://web-static-cloudfront.s3.amazonaws.com/images/wiki/image1.png

Then click on "configure", you will want to tell Jenkins to grab your source code from git:

http://web-static-cloudfront.s3.amazonaws.com/images/wiki/image2.png

User configuration (for example)

http://web-static-cloudfront.s3.amazonaws.com/images/wiki/image3.png

Also - this will show you a public key that you can put add to github to allow DEV@cloud to pull out the source code as needed. In the git section copy the whole public key blob of test, and then go to github, click on "account settings" and then add this as a key to your account: 

http://web-static-cloudfront.s3.amazonaws.com/images/wiki/image4.png

Now to get DEV@cloud to run your build on source code change, you can either poll:

http://web-static-cloudfront.s3.amazonaws.com/images/wiki/image5.png

(which will pull changes in as they happen, almost). OR, you can push from github. To push, you will need to go to Admin, then "service hooks" and then "post receive URLs". You then put in a URL of the format:
https://CBUSER:PASS@CBACCOUNT.ci.cloudbees.com/job/JOBNAME/build - you will need to URL encode your user name as it will have an "@" in it (user name is email). 

Finally, you setup the build command: 

http://web-static-cloudfront.s3.amazonaws.com/images/wiki/image6.png

(of course with your appropriate key information)

 

From here on - every time a code change is made the build will be run, and the code pushed to the nominated appid. For extra points, you could use the Promotion plugin for Jenkins, and have rules that control when an application is deployed to an appropriate appid (ie production, versus test). 

We (CloudBees) use this setup in multiple places - including cloudbees.com. Hope this helps you !

Created by Michael Neale on 2011/07/20 06:52
 


All Rights Reserved - CloudBees, Inc. - 2012
XWiki Enterprise