Using Windows Explorer With TortoiseGit on OpenShift

Installing TortoiseGit and managing SSH Keys

Step 1: Ensure you have the proper permissions

You must have access and permission to install new software on your system. Depending on how your system is configured, you may need to disable User Account Control (UAC) or have the permission to accept new software installation.

Step 2: Install TortoiseGit interface

TortoiseGit authors describe it as “The coolest Interface to Git Version Control”. It can be used to provide access to your OpenShift cloud applications’ code.

To install this software, download the latest package from http://code.google.com/p/tortoisegit/downloads/list and follow the instructions.

Execute TortoiseGit installer.

tortoise-git-installer-for-openshift

When prompted for SSH client, choose default option of TortoisePlink, which integrates with Windows better.

OpenShift TortoiseGit ssh configuration screen image

Complete the installation.

OpenShift Tortoise Git install progress screen

Step 4: Convert SSH Keys to Putty format

Note: You need to execute this step only once.

When rhc tools are installed, your SSH keys are created in the OpenSSH format. This format differs slightly from the PuTTY format. In this step, we’ll import the OpenSSH key that you have created earlier and convert it to native PuTTY format, also compatible with TortoisePlink.

Select Start -> All Programs -> TortoiseGit -> Puttygen

In Puttygen, select Conversions -> Import Key

OpenShift Tortoise Putty Key Import screen image

By default, OpenSSH stores your keys in drive:\Documents and Settings\user.ssh folder on WindowsXP, or in drive:\Users\user.ssh folder on Windows 7. In the file selector, navigate to this folder and select id_rsa file that contains your private key.

You may see another file that is actually a public key id_rsa.pub — Windows may misidentify it as a ‘Microsoft Publisher’ file. If you try to select id_rsa.pub, Puttygen errors that this file does not contain a private key.

Once imported, you will see the following imported information in Puttygen.

OpenShift Tortoise Putty ssh keygen screen image

Then, click on Save private key and choose the same drive:\Documents and Settings\user.ssh folder. The file name will default to id_rsa.ppk.

You should now have three files in this folder: OpenSSH private key id_rsa, PuTTY private key id_rsa.ppk and public key id_rsa.pub.

OpenShift Tortoise Putty shortcut icon in Windows explorer image

We will use these keys in the following sections when accessing your application securely.

Using TortoiseGit with a new OpenShift application

In this section, I will describe steps to create a new OpenShift application and to access and modify your application using TortoiseGit and Windows Explorer.

Step 1. Create an application.

Let’s create a sample application based on the Kitchensink JBoss example available at https://github.com/openshift/kitchensink-example. Kitchensink quickstart shows off all the new features of Java EE 6, and makes a great starting point for your project.

Open Windows command prompt and run the following command as instructed in the example:

Create a jbossas-7 application

`rhc app create kitchensink jbossas-7
`

Add this upstream kitchensink repo

`cd kitchensink
git remote add upstream -m master git://github.com/openshift/kitchensink-example.git
git pull -s recursive -X theirs upstream master
`

Then push the repo upstream

`git push
`

That’s it, you can now checkout your application at:

`http://kitchensink-$namespace.rhcloud.com
`

Step 2. Enable access by loading your SSH keys into Pageant.

In order to access your application, let’s load your SSH key to provide authorization. Pageant is an SSH authentication agent and a part of the PuTTY suite of utilities.

Select Start -> All Programs -> TortoiseGit -> Pageant

**Pageant **will run in the Notification area.

OpenShift TortoiseGit notification area image

Right click on Pageant **icon and select **Add Key. Navigate to the id_rsa.ppk key that you have previously created in drive:\Documents and Settings\user.ssh or drive:\Users\user.ssh and select it.

You will see **Pageant **loading this key when you double click on **Pageant **icon.

OpenShift TortoiseGit ssh key list image

Step 3. View and Pull your application via Windows Explorer and TortoiseGit.

Using command line tools, your application has been already created and loaded into a drive:\Documents and Settings\user\kitchensink folder.

Navigate to this folder and verify that your application is current. Right click on kitchensink and select TortoiseGit -> Pull.

OpenShift TortoiseGit windows explorer image

Verify that remote is set to origin.

When git pull is complete, select close.

If you get an authentication error, make sure that **Pageant **is running and that it has your SSH key loaded.

Step 4. Edit and Push your application via Windows Explorer and TortoiseGit.

For simplicity, we’ll edit a simple HTML file using notepad.

Using Windows explorer, navigate to drive:\Documents and Settings_user_\kitchensink\src\main\webapp folder.

Edit file index.xhtml with your favorite editor and make a simple one-line change. Once the file is changed, Tortoisegit will detect the change and display a different icon for your file.

OpenShift TortoiseGit windows explorer image

Right-click on changed file and select Git commit -> “master”. Tortoisegit commit interface will open.

Add a comment to your change and click on OK.

OpenShift TortoiseGit windows explorer image

Your commit has been successful. Now, select Push from the dropdown menu (do not Close).

OpenShift TortoiseGit git push image

In the interface, select Remote destination as origin and click OK.

OpenShift TortoiseGit image

After a minute or so, your application has been uploaded.

If you get an authentication error, make sure that **Pageant **is running and that it has your SSH key loaded.

Now, point your browser to

http://kitchensink-$namespace.rhcloud.com

and review your edit.

Using TortoiseGit with an existing OpenShift application

In this section, I will describe steps to access and modify your existing OpenShift application using TortoiseGit and Windows Explorer.

When creating your application via a Web Console, you will see instructions for accessing your application under Next Steps.

OpenShift TortoiseGit image

Scroll down to **Making code changes **section.

OpenShift TortoiseGit image

Alternatively, you can access this information via the OpenShift Management Console **by selection **My Applications **tab and then choosing your application. You will find it listed as this application’s **git repository.

Select a string starting with _ssh:// _as shown in the image above and choose Copy via a right-click or a shortcut Ctrl-C.

Then, navigate to a folder where you will prefer to store your application, for example, drive:\Documents and Settings_user_\ , right-click on an empty space and select Git Clone from the menu.

Openshift git explorer image

A Tortoisegit window will open with a prepopulated string from your Windows clipboard.

Verify that the **URL **section matches the string above. **Directory **is where your application will be placed.

Lastly, select a PuTTY key that we have created in Section 1. Navigate to the **id_rsa.ppk **key in drive:\Documents and Settings\user.ssh or drive:\Users\user.ssh and select it.

When finished, click OK.

Openshift putty key for tortise

When finished, your can now view and edit your application source code using the ## Explorer. See Step 4 in the previous section of this blog to view the screenshots for editing and pushing your application to OpenShift.

Categories
News
Tags
, , ,
Comments are closed.