Posts Tagged ‘ssh’

Connecting to an existing Cloudbees repository from Windows

December 29, 2012 Leave a comment

This post is the result of trying to figure out how to setup a repository clone of one of my projects on my windows machine.  I work on my Mac most of the time, but at times it’s more convenient to work on my Win machine (usually when I have to debug IE issues, and need to try js fixes to see what impact they make)

So, lets start by setting up our tools and IDE on Windows.  We obviously need Java, Eclipse, and Maven, and actually that’s it.  In Eclipse, install m2e and EGit plugins.  Make sure you follow all the installation instructions for Maven with all the variables in the right place.

Now we need to setup SSH.  This needs to happen in two places, in Eclipse settings and in Cloudbees settings.  Here are the steps:

  1. In Eclipse, go to preferences->General->Network Connections->SSH2, select key management, and generate a DSA key.  Enter the pass phrase and remember it, you’ll need it in a minute.  Copy the public key to the clipboard.
  2. Click “Save private key” and save it, go to general and add the saved private key.   Apply and save.
  3. Go into Cloudbees settings->SSH keys, choose a name and paste the public key from the clipboard.  Click “Add”.
  4. Go to Cloudbees->Repositories, go into your project and copy to clipboard the SSH url unique to your repository.
  5. Go back to Eclipse, File->import, choose Git->Projects from Git.  Choose URI and paste the SSH URL you copied from your repository.  Choose ssh as the protocol.  The user should be git, and password empty.  Port can remain empty (it will be filled with the default which is 22)
  6. You will now need to enter your pass phrase.
  7. Next next next and your project will be cloned locally.
  8. To help maven work you need to go into Eclipse->Preferences->Maven, and go to installation->Add and pick the Maven installation you installed locally (instead of the Embedded one).
  9. If you run into problems with your project when you open the IDE, see this post.  If you still have problems, and you had Maven installed before, try deleting the .m2 resources directory.  You might also need to go into Preferences->Maven->User settings and reindex or update settings.
  10. Your project should automatically compile.

Problems you may encounter:

1. M2E installation fails and maven does not seem integrated into eclipse.  I couldn’t fix that and had to reinstall eclipse

2. You get complaints about javac and JRE: you’re using JRE instead of JDK, switch to JDK in eclipse->java->installed jdk’s

Categories: R&D Tags: , , , , , , ,

Creating an online service – Using cloudbees for Continuous Deployment with Basic Service based projects

November 5, 2012 2 comments

The previous post discussed getting the basic service application to your local development environment and getting it setup.  In this post I’ll describe the process of setting up cloudbees for working with a Basic Service like project, so we can close the loop all the way to production.

We’ll be using cloudbees’ SEND-GRID services to send emails (registration verification process uses it to send a confirmation email), so before going further, go into cloudbees->services, and activate SendGrid.  You can pick the free account for now.

Before creating a new git repository in cloudbees, we need to do some housekeeping in Git.  Git has a file called .gitignore, which helps tell git what you don’t want to monitor and commit.  At the very least, add the following entry:


to the .gitignore file (create the file if it does not exist in your main project directory).  This will prevent you from accidentally checking in your targe directory (which is built automatically by the cloudbees CI environment).  Now that we have this covered, it’s time to get started.

Setting up a git repository in cloudbees is easy, just pick Repositories->create new repository, give it a name and pick Git as your repository type, and click enter.

Once that repository is done, you need to connect your local repository to the cloudbees one so you can push your code.  After creating your repository, you will see some helpful short examples of how to connect to cloudbees (just below the details paragraph).  Pick “Migrating to your cloudbees repository”, and follow the steps.  Don’t pull/push from legacy, just use the remote rm command to remove the old repository.  Alternatively, you can delete the .git directory and start a new git repository from scratch (without the basicservice history).  Just follow the “committing an existing project to git” cloudbees instructions to do that instead.

You repository should now be about 0.6MB, and contain the project files.

Once you’ve setup your repository, the next thing you need to do is setup a Build configuration.

Before going to builds, open your repository details, and copy the uri starting with ssh:// (you will need it shortly)

Hit builds, and create a New Job.

Give it a name, and pick “Build a maven 2/3 project”.  Hit next.

Mark “one click deployment”, select “Oracle 1.7 latest” as your JDK, unclick “restrict where this project can run”, select “git” as your repository.

In the git url paste the ssh:// url you copied earlier.  Put two stars (**) in the branches to build input field.

In build->goals and options put: clean install

In post steps, select “run only if build succeeds”, in the build settings, mark the email notification and add your email so you get notified of checkins and builds.

Pick “abort the build if it’s stuck” and pick whatever makes sense to you (I chose elastic)

Add a post-build-action and deploy-to-cloudbees, add web application and pick “maven artifact selection”.  Add an application id (your project name is fine).  Click “Advanced”, and enter production in the “Environment” field.

Don’t worry about the “not found” warning, click save.

Click build Now, and when an available worker is ready your project will start building. Click the running build and then console Output to see the process in action.  When the build is complete, you should see something like:

[cloudbees-deployer] Deployed to application id your_account/your_project
[cloudbees-deployer] Can be accessed at

Click it and start playing around with your production online service!

One last small thing left to do: setup our domain.  We’ll cover this in the next post.

Categories: R&D Tags: , , , ,

Copying a git repository from Cloudbees to Github

October 16, 2012 Leave a comment

I recently had to take my cloudbees hosted repository hosted on, well, cloudbees, and move it to github.  This was a bit tricky for someone will little knowledge of ssh and git (me), so hopefully if you’re in my situation this will help.  Note that this was done on a Mac OSX, should be similar for other unix based OS’s but probably slightly different for Windows.

I’ve used green color to represent terminal commands, so if you see something in green, it obviously needs to go into terminal…

First create a new account and repository on github.

Once you do that, you need to setup your ssh connection to git (you can also connect using http, but I’ll stick to SSH for now).  There’s a pretty good explanation by git-hub here, which I followed (well, some of it), but basically here’s what you need to do:

  1. Go to command terminal, and enter the following command which will copy your ssh public key to the clipboard
    pbcopy < ~/.ssh/
  2. If was not found, you need to generate a new ssh key locally, follow the git-hub tutorial mentioned above to do that.
  3. Go to your github account settings->ssh keys, and click “add SSH key”.  Give it a name and paste your key.
  4. In terminal, enter
    ssh-add -l
  5. This should give you a print of your key hash, make sure it is identical to what you see in your git-hub listing.  It should look like this:
  6. In terminal, go to your repository directory (e.g. ~/code/basicservice/)
  7. make sure you have a git repository there:
    git status
  8. Create a new repository on git-hub, don’t initialize it with README
  9. Push your repository to git-hub
    git push<youraccount>/<your-repository>.git master
    you can get the git url from your git repository page, make sure you click on SSH to get the right url, or just replace <youraccount>/<your-repository> with your data.
  10. That’s it.  Your repository is now hosted on git-hub as well, you can now drop the cloudbees repo and start using git-hub.  To make it push both to cloudbees and to github simultaneously (if you want to keep both) you need to add some configuration, and I’ll pass on that right now.  You can check out this post for help on that.
Categories: R&D Tags: , , , ,