Monday, November 4, 2013

Tracking custom Jira queries

One of the powerful capabilities of Just the Facts is subscribing to result counts from any Jira query.  For example, an engineering manager is using this to track his compliance to his customer service level agreements (SLAs).

Each issue reported by customers is tagged with an SLA custom field, where each value corresponds to a committed turn-around time:


SLA LevelTurnaround Time
11 day
23 days
32 weeks

The number of overdue issues at any given time can be tracking with a custom Jira query.  For example, the following JQL returns all SLA level 1 issues that have been open for more than 1 day and that are still unresolved:

project = HIL and "SLA"="1" AND resolution=Unresolved AND created  < startOfDay(-1d) 

and a similar query tracks the SLA 2 issues:

project = HIL and "SLA"="2" AND resolution=Unresolved AND created  < startOfDay(-3d) 

To subscribe to these queries, this manager enters this query into Jira, activates the Just the Facts extension, and selects the field listing the result count:

Subscribing to Jira Story Count
After the fact is created, he selects the fact, labeled "Number of Issues" by default, and edits it to give it a more descriptive label:
Selecting a Newly Created Fact
Editing a Fact
After subscribing to the counts for the other SLA levels, he can also create a single, combined fact that totals the count of all overdue issues:

Selecting Several Facts

Creating a Combined Fact
 and set a warning if it goes above a specified number:

Selecting a Combined Fact

Setting a Warning
Going forward, this manager's daily email report will include these overdue issue counts.
Daily Report


Monday, October 21, 2013

Subscribing to Behind-the-firewall Jenkins

You can use Just the Facts to subscribe to build results from Jenkins, including failed test counts, coverage levels and lint results.  The process is straight-forward if your Jenkins instance is publicly available or on a hosted service such as CloudBees:

  1. Navigate to your latest build results and activate the Just the Facts plugin:
  2. Select the facts you want to subscribe to and click "Subscribe".
  3. Enter your Jenkins account information, available from the configuration screens:

However, what if you are hosting Jenkins behind a firewall, so that public services like Just the Facts cannot access it?

In this case you can use the Just the Facts REST API to push the results of each build.

The API endpoint is http://www.just-facts.co/api/v1/fact and it takes the following arguments:

  • account - the email address you used to sign up for Just the Facts 
  • service - each supported service has a constant value, such as JENKINS.
  • metric - each supported service has a fixed set of available metric names.  For Jenkins, the available names are:  test, coverage, codenarc.
  • value - the current value for the specified metric.
  • url - optional, the url-encoded value for the dashboard containing the fact

Any additional URL arguments will be added as metadata for the fact.

For example, to set a value for number of tests failed for a project named justfacts-ci hosted at http://cb1.just-facts.co:8080/job/justfacts-ci, you would use a URL of the form:

http://www.just-facts.co/api/v1/fact?account=prose@justfacts-beta.com&service=JENKINS&metric=test&value=3&Project=justfacts-ci&url=http://cb1.just-facts.co:8080/job/justfacts-ci

One approach to incorporating this call into your build results is to use the Groovy Postbuild plugin.  As the name suggests, it lets you execute an arbitrary Groovy script as a postbuild step.

To set this up, add the plugin to Jenkins, go to your build configuration, click "Add post-build action," select 'Groovy Postbuild," and enter the following script:

int failedTests = 0
def pattern = /Completed (\d+) (.*) tests, (\d+) failed(.*)/
def logger = manager.listener.logger
manager.build.logFile.eachLine { line ->
    def m = line =~ pattern

    if (m?.count > 0) {
        failedTests += m[0][3] as int
    }
}

def account = 'prose@justfacts-beta.com'
def jenkinsUrl = 'http://cb1.just-facts.co:8080/job/justfacts-ci'
def projectName = 'jenkins-ci'
def url = "http://www.just-facts.co/api/v1/fact?account=${account}&service=JENKINS&metric=test&value=${failedTests}&project=${projectName}&url=${jenkinsUrl}"
def result = new URL(url).getText()
logger.println(result)

substituting your own values for the account, jenkinsUrl, and projectName variables.

This will scan the build results for test results, sum up any failures, and report that as the new count.

This configuration is ideal for daily builds, which report results once a day.  It can also be used for continuous integration builds; the most recent result for a given calendar day will be stored as that day's value.

Saturday, September 28, 2013

Tracking your combined social reach

Just the Facts not only lets you monitor and alert on facts from individual web service, but also lets you combine them into calculated facts.  This post will step through creating a single fact, "Combined Reach," that collects the follower counts from a number of social networks.

Let's say I have multiple social presences, spanning Facebook, Twitter, Pinterest, and YouTube.  But what I really want to track day by day is my overall social presence.

After I've signed up for Just the Facts and installed the Chrome plugin, I begin by navigating to each of my social networks and activating the plugin.  Let's start with my total number of Twitter followers:

Subscribe to Twitter Followers
I click on the hilighted Followers field to select it and click Subscribe. I then click Authorize app to give permission for Just the Facts to make API calls to my Twitter account.

Twitter Permissions Dialog
That's it!  My Twitter Followers count will now be tracked daily and emailed to me.

Subscription to Twitter Followers
I can follow the exact same steps for my other social network, capturing facts for Facebook Friends, Pinterest Followers, YouTube Subscribers, and Google+ circles:

Facebook Friends
Pinterest Followers
YouTube Subscribers
Now I can create what we call a Calculated Fact by selecting the newly created facts and clicking the Combine into New Fact icon.
Combine into New Fact
Let's call our new Fact "Total Reach" and click Save.

Defining "Total Reach"
We can then edit our newly created Fact to set a Target value:
Editing a Combined Fact
Setting a Target
This lets us track progress towards the target every day.  We'll also receive an email notification when the target is reached.
Email Notification
These are just some of the social networks supported by Just the Facts - others include LinkedIn and Google+.  Click to see the full list of supported services, and remember that more are being added all the time.  

What additional services would you like to see and what facts are you interested in tracking?  Let us know in the comments below.