What do i want to test.
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.
Here is how to do such a thing :
- – First Of all you need to go to your Jenkins instance on Cloudbees, and then go to :
Administer Jenkins / Configure System
- – Then in the Jenkins settings page find the
[Cloudbees][Cloudbees] DEV@Cloud Authorizationsection and copy the
[Cloudbees][Cloudbees] Public Key.
- – Now go on BitBucket and go to your account settings, and select
SSH Keyson the left menu. In the SSH Keys page fill the
Add a new keyform with a name (cloudbees for example) and paste the key you’ve just copied on step 2. Then submit the form.
- – Now your CloudBees Jenkins instance should be able to access your private repositories
Now deploying on Heroku
heroku keys:add PATHTO/cloudbees.pub
Now Cloudbees can publish on Heroku…
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 …