Creating a Jenkins continuous integration on Windows Azure

You can create a Jenkins VM very quickly with this approach.

  • Create a storage account for your VMs if you don’t have one.

  • Create an image from VM Depot (choose Jenkins).

  • Choose the storage account where the image will be copied (the one you created in the first step).

This process will take approx 20 minutes (it will copy the base vhd image template to your account which could be a couple of GB)

  • Once it finished copying, create the VM by clicking on NEW -> Virtual Machine -> From Gallery and choose the Jenkins image

  • Give it a name and choose an Extra Small instance. That’s enough to start with. You can scale up easily later, with one click. This should take between 5 to 7 minutes.

If you want to ssh into the machine to install stuff, you can also upload your public key (you can create one with: openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -subj "/CN=jenkins" -keyout jenkins.key -out jenkins.cer)

  • Once it finished, open endpoint 80 (takes 2 minutes max)

  • Now, you can browse the new Jenkins (

  • Enter the app and use the following credentials (user: user and password: bitnami).

More users can be added later or you can configure the GitHub OAuth plugin to authenticate with github accounts

Create a job, configure GitHub and Windows Azure Web Sites repos

  • Now let’s install the GitHub plugin. Go to Manage Jenkins -> Manage Plugins. Install “GitHub Plugin” (if plugins are not there, keep refreshing and they should appear soon)

  • Click on “Install without restart”

  • Click on Configure System. Set Github y to something arbitrary like “build”

  • Next, create a new job and choose “Build a free-style software project”

  • Click on Git radio button and add your GitHub repository. IMPORTANT: use the git read only endpoint from GitHub which has this form git:// This is a quick way of doing it, the other option is to copy your SSH keys to the VM, but since you will always READ from GitHub, this is ok.

  • Then, add the azure repository using a URL like this Notice, that in order to get that endpoint you would need to have enable the “Local Git Repository” option in Windows Azure Web Sites. You can find the URL of the repo in the Azure Web Site dashboard.

  • Click on Advanced and give it a name like “azure”

Create a post build action to push to Windows Azure Web Sites

  • Add a Post-build action of type Git publisher. Click on Push Only If Build Succeeds. Then, click on Add branch to configure the branch and target we want to deploy. Enter the following * branch: master * target: azure

Configure the GitHub web hook to automatically build on push

  • Make sure to check Build when a change is pushed to GitHub on the job

  • Go to your GitHub repo on and click on Settings, then Service Hooks and look for ”Jenkins (Github Plugin)”. Use the following URL (replacing the DNS).

  • Push a change to github and you should see it will start building

  • If you go to the Azure Web Site you will also see that it pushed a new build

Customize the environment

Usually you will want to run tests and do a lot of things. For instance, in Auth0 our job will run npm install, then run our unit and integration tests with mocha. If everything runs fine, it will push to the web site.

If you uploaded a public key you can SSH to the VM with:

ssh -i jenkins.key -p AZURE_PORT

Where user is the user name you set when creating the VM on the Azure portal and AZURE_PORT is the one you will find in endpoints. Also, make sure to have the private key protected with sudo chmod 600 jenkins.key

You can install node.js like this

sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

Published: April 21 2013

blog comments powered by Disqus