Posted on Leave a comment

Linking JIRA to GitHub to streamline agile workflow

Jira Logo

In order to automatically track and link the progress of your JIRA issues based on your developers’ commits in your Github repositories make sure to checkout the JIRA DVCS connector addon.

It only takes a few simple steps to link your JIRA projects to your GitHub repositories to streamline your agile workflow, as shown below. First, you’ll need to register a new application for your main GitHub account, in order to generate OAuth tokens required to link JIRA to GitHub:

Generate OAuth tokens in GitHub

Choose JIRA DVCS for the application name and your full base URL of your JIRA cloud-based setup for Homepage URL and Authorization callback URL:

Configuring DVCS connector URL in GitHub Once you’ve registered your new application you will get the OAuth tokens (client ID and client secret) required by the JIRA DVCS connector:

Configure DVCS connector using OAuth tokens in GitHub

Now that you have your OAuth tokens it’s time to setup the JIRA DVCS connector. Thus, open the Administration > Source Control > DVCS Accounts tab in JIRA and select Link BitBucket or GitHub account:

Link JIRA DVCS to GitHub using OAuth tokens

There you’ll need to enter the OAuth tokens generated in GitHub:

Link JIRA DVCS to GitHub using OAuth tokens

Feel free to select Auto Link New Repositories and Enable Smart Commits when needed. Once you’ve added the tokens you get a list of your authorized GitHub repositories (public and private, depending on the permissions chosen for the GitHub application) that are now available to JIRA:

Checking available GitHub repositories from within JIRA DVCS


Final Step

The last thing to do is to check that your developers have the proper rights for the View Development Tools permission:

Setting View Development Tools permission in GitHub

Now that everything is set up properly remind your developers to use the JIRA issue ID in the commit messages so that the JIRA DVCS connector is able to automatically assign commits to your issues.

Further reading is available here: Streamlining your development with JIRA.

Posted on Leave a comment

Adding advanced formatting to Harshen’s jQuery countdown timer plugin

jQuery Logo

Harshen’s jQuery countdown timer plugin works great and is simple to use. In a recent project we needed to use special formatting for the countdown timer to be implemented. Although, Harshen’s solution offer to timeSeparator option to specify the separator string to be used this was not flexible enough. The customer wanted the countdown timer to display the remainder time in the format:

ddd / ddh / ddm / dds

Although, using the timeSeparator option it is possible to get the separating “/” to work, we needed the days(d), hours(h), minutes(m) and seconds(s) formatted using HTML.

The plugin extension

Having a quick look at the plugin to only thing to do was to overwrite the $this.html() functionality by a custom function that takes care of processing additional formatting rules. In order to keep the formatting as flexible as possible I opted to add regulare expression support through additional options:

  1. regexpMatchFormat
  2. regexpReplaceWith

regexpMatchFormat specifies the format to match the original output string produced by the plugin. regexpReplaceWith then takes care of replacing the original string with the desired regular expression format. Furthermore, an additional function called html was introduced:

 * Replaces content by optional regular expression specified via options 
 * regexpMatchFormat and regexpReplaceWith.
 * @param Object $this
 * @param String content
function html($this, content) {
  var processedContent = content;

  if (typeof window['regexpMatchFormat_' + $this.attr('id')] !== 'undefined' &&
      typeof window['regexpReplaceWith_' + $this.attr('id')] !== 'undefined') {
    var regexp = new RegExp(window['regexpMatchFormat_' + $this.attr('id')]);
    processedContent = content.replace(regexp,
      window['regexpReplaceWith_' + $this.attr('id')]);


Handling of the addtional two options was added in the countdown function:

var regexpMatchFormat = "";
var regexpReplaceWith = "";
if (options.regexpMatchFormat != undefined && options.regexpReplaceWith != undefined) {
  window['regexpMatchFormat_' + $this.attr('id')] = options.regexpMatchFormat;
  window['regexpReplaceWith_' + $this.attr('id')] = options.regexpReplaceWith;

Below you find the regular expression used for this project’s requirements:

<script type="text/javascript">// <![CDATA[
jQuery(document).ready(function ($) {
      dateAndTime: "2015/01/01 00:00:00",
      size: "lg",
      regexpMatchFormat: "([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})",
      regexpReplaceWith: "$1<sup>d</sup> / $2<sup>h</sup> / $3<sup>m</sup> / $4<sup>s</sup>"
// ]]></script>

Thanks again to Harshen for the very nice plugin 🙂

Posted on Leave a comment

Using multiple SSH Keypairs for Git

Git Logo

When using multiple (GIT) services and repositories from different provider you are very likely to also use different sets of SSH keypairs. At first managing multiple keypairs might sound a little complicated but it is in fact quite easy.

Let’s say you have three keypairs for three different GIT services:

  • GitHub
  • PHP Cloud
  • your local GIT server

In order to separate access to these services you are using different keypairs for each service. In order to tell GIT to automatically choose the right keypair for the service you are trying to access you need to edit your local SSH config file (.ssh/config), as well as the GIT repository’s config file (.git/config).

First, you need to create an alias for each service in your SSH config file:

Host phpcloud-mycontainer
  User mycontainer
  IdentityFile ~/.ssh/id_rsa.phpcloud-mycontainer

Host github-myaccount
  User myaccount
  IdentityFile ~/.ssh/id_rsa_github-myaccount

Host localgitserver-myaccount
  HostName localgitserver.local
  User myaccount
  IdentityFile ~/.ssh/id_rsa.localgitserver-myaccount

As you can see three aliases have been specified for the three services. This provides you with the option to specify what key to use depending on the service.

In order to “activate” these alias for existing repository clones you need to edit .git/config to set the proper remote origin. So for instance your config for GitHub would look something like the following:

[remote "origin"]
  url = ssh://git@github-myaccount:myaccount/myrepo.git

Now all you need to do is the use the alias when accessing your services. This way the proper SSH key will be determined.

Also note that this approach is not limited to GIT – you are able to use these simple steps for any service based on SSH.