First Tests on Cloud ! CloudBees And Heroku

When I went to DevoXX France, everyone was talking about Cloud Services, like Cloudbees or Heroku. I didn’t looked before at those services, but I was able to do it last week !

What do i want to test.

I am using BitBucket Git platform for many of my projects, and I use Jenkins as A continuous Intergration Server.

Cloudbees offers a Jenkins Instance on the Cloud, So The first Think I want to try is Jenkins Build from my BitBucket Projects. But many of my projects are private, so Cloudbees should not be able to acces my repositories.

Giving CloudBees access to BitBucket private repositories

BitBucket use ssh keys to authenticate users on repositories.

Cloudbees create a public key for your Jenkins instance

So in order to give Cloudbees acces to my BitBucket Repositories i had to add the Cloudbees public key to my BitBucket[BitBucket Account.

Here is how to do such a thing :

  1. – First Of all you need to go to your Jenkins instance on Cloudbees, and then go to : Administer Jenkins / Configure System
  2. – Then in the Jenkins settings page find the [Cloudbees][Cloudbees] DEV@Cloud Authorization section and copy the [Cloudbees][Cloudbees] Public Key.


  1. – Now go on BitBucket and go to your account settings, and select SSH Keys on the left menu. In the SSH Keys page fill the Add a new key form with a name (cloudbees for example) and paste the key you’ve just copied on step 2. Then submit the form.


  1. – Now your CloudBees Jenkins instance should be able to access your private repositories

Now deploying on Heroku

Heroku also use Public Keys for authentications. So you’ll need to add the Cloudbees Jenkins Public key to Heroku.

Create a file ( and paste the Cloudbees Jenkins public Key in it, now excute the folowing command :

heroku keys:add PATHTO/

Now Cloudbees can publish on Heroku…

Cloudbees, (Jenkins) when running construction job will do a

git clone

So you will need to add the remote Heroku location, and then it will have to do a

git push heroku master

, so you will have to edit the construction job by adding some build steps :

In the job configuration page, add a build step after the construction step, I made a shell script step with this content :

git remote add heroku YOUR_HEROKU_GIT_URL
git push heroku origin:master

This Should work once, but the second time the job will run, it will fails because heroku remote already exists … simply remove the first line of the shell script.

I know that it’s not the best way to do, i’ll update this post when i’ll improve this script …

Done !