Posts Tagged ‘Ruby’

Something’s A-Twitter in My Backing Stream

June 22nd, 2010 by amonty

One of the cornerstones of any successful organization is communication. On Agile teams, we often meet to share information, update one another on progress, to reflect on that progress and discuss how the process can be improved. These interactions, be they stand-up or retrospective meetings, provide this information at regular intervals. But what if you need “real-time”  information sharing?

Consider the concept of “one piece flow”, often treated as the holy grail of engineering process purists. Lean/Kanban fan boys live to talk about this at conferences, and in the isle outside my cube. The idea is that a single “workpiece” at a time moves through the workflow. In the software development process, this is rarely limited to a single item, but instead is throttled by WIP limits to minimize the bottlenecks in the process. For example, the number of items worked on by developers is limited so that the count of items designated “ready for test” is kept at a manageable level. As a tester on an agile team, I’d like to know as soon as an item is moved from the “wip/development” phase to the “test/validation” phase.

Consider the following basic stream structure -

Simple Stream Structure

In an ideal model, testers would be notified as soon as an issue is promoted from the WIP stream to the Validation stream. This model assumes that the project is utilizing AccuRev change packages to track work items as issues. Having a distinct stream for validation purposes simplifies the job of the tester. All issues that exist in this stream have been unit tested by developers, passed basic regression tests, and are ready to be explored, validated, and promoted to the next stage in the workflow.

So, how can this level of communication be achieved? AccuRev triggers! The rest of this post will demonstrate how the server post-promote trigger could be used to provide updates using arguably the king of “What’s Happening?” – Twitter.

Why use Twitter in your Backing Stream?

Why not? Sure, you could use e-mail. But who wants more e-mail? Tweet it, and let them aggregate the information for you. Team members can follow the account, or not. Pointy-haired managers that dream of pie charts and love visibility can subscribe to an RSS feed, that you don’t have to manage. Lastly, if you’re an agilista, you’re already hip and trendy, (and let’s face it, you probably  already tweeted about the awesome presentation on Lean that you saw at the latest Agile conference).

The Server Post-Promote Trigger

I am not going to go into the gory details of the AccuRev trigger system. Here’s what you need to know.

  1. The trigger can be written in whatever language you like. In this example, I use Ruby.
  2. The trigger needs to be registered with the AccuRev server, and associated with the depot for your software project.

For this exercise, I wrote a quick script called tweet_post_promote.rb. The first step is to register this script with AccuRev.

>accurev mktrig -p SoftwareProject server-post-promote-trig ~/dev/ruby/tweet_post_promote.rb

Once registered, the trigger will now fire for all promotes in the SoftwareProject depot. Let’s take a look at the contents of the script.

#!/usr/bin/env ruby

require ‘rubygems’

require ‘crack’

require ‘twitter’

ACCUREV_DIR = “/sandbox/amonty/accurev/”

ACCUREV_STORAGE = “#{ACCUREV_DIR}storage/”

ACCUREV_SITE_SLICE = “#{ACCUREV_STORAGE}site_slice/”

USER = ‘ValidationBot’

PASS = ‘password’


def load_trigger_data(file)

xml = ”

File.open(“#{ACCUREV_SITE_SLICE}#{file}”) do |f|

xml = f.read

end

Crack::XML.parse(xml)

end


def twitter_get_auth(user, pass)

httpauth = Twitter::HTTPAuth.new(user, pass)

Twitter::Base.new(httpauth)

end


def main()

hash = load_trigger_data ARGV[1]

if hash["triggerInput"]["stream1"] == “Validation” then

changePackageIssue = hash["triggerInput"]["changePackages"]["changePackageID"]

update_string = “Issue #{changePackageIssue} just promoted to stream #{hash["triggerInput"]["stream1"]}”

twitter = twitter_get_auth(USER, PASS)

twitter.update update_string

end

end

main if __FILE__ == $0

This script is very simple. It makes use of the Ruby gems crack and Twitter. Essentially, the script takes the XML trigger file (provided as ARGV[1]) and loads it into a hash. Then the script checks to see if the stream being promoted to is our Validation stream. If so, it uses the twitter gem to update the status on our ValidationBot account.

Something's a-Twitter in my backing stream

A more useful example is to provide a link to the AccuRev Web UI Issue screen.

Something's a-Twitter in My Backing Stream

This way, anyone subscribing to the feed can click on the link and open the issue in the AccuRev Web UI.

Something's A-Twitter in My Backing Stream

This is a small example of how AccuRev triggers can be used to increase communication on your team. Testers can follow the ValidationBot account and be notified via their favorite Twitter client whenever an issue is promoted to the validation stream and they need to begin work on it. This could obviously be extended to include additional information (actual file changes, for example). That is, of course, if you can fit it into 140 characters. :)

For more information on AccuRev triggers, please see the Administrator’s Guide.

Developer Recipes: AccuRev + Eclipse + Ruby

September 18th, 2007 by dave

Related Recipes: AccuRev + JIRA + Eclipse (using Mylyn)

Love Ruby? Use Eclipse? Got AccuRev? Here’s a recipe guaranteed to get the mixture setup… stirred, not shaken.

Install Applications

  1. Install AccuRev 4.5. download. Follow the executable wizard.
  2. Install Eclipse 3.2. download. Follow the executable wizard.
  3. Install Ruby 1.8. download. Follow these instructions.

Install AccuRev Plugin in Eclipse

  1. Help –> Software Updates –> Find/Install
  2. Select ‘Seach for new features to install’
  3. Create ‘New Remote Site’ named AccuRev with URL http://www.accurev.com/download/eclipseupdate
  4. Checkbox ‘AccuRev’ and select Finish

Install Ruby Plugin in Eclipse

  1. Help –> Software Updates –> Find/Install
  2. Select ‘Search for new features to install’
  3. Create ‘New Remote Site’ named Ruby with URL http://updatesite.rubypeople.org/release
  4. Checkbox ‘Ruby’ and select Finish

Lets Rock! Now that the software is installed, lets put it to work. Here are three use-cases depending on how you need to work on your project.

Use Case: New Eclipse project / New AccuRev workspace. Starting from scratch? Have ruby code already in a depot? Do you know which stream configuration you want to work from? Then this is for you…

  • File –> New –> Project –> AccuRev –> Checkout from AccuRev
  • Choose “Create new AccuRev workspace and Eclipse project”
  • Follow the wizard to specify depot/stream/project/workspace names and directory location. Select ‘simple project’ when prompted for project type.
  • Select project in navigator. Project –> Add Ruby Nature. This will declare the project as a ruby project.

Use Case: New Eclipse Project / Existing AccuRev workspace. Already have an AccuRev workspace with your ruby code? Just need to setup a new eclipse project? Then this is for you…

  • File –> New –> Project –> AccuRev –> Checkout from AccuRev
  • Choose “Create new Eclipse project in existing AccuRev workspace”
  • Follow the wizard to select the workspace and name the project. Select ‘simple project’ when prompted for project type.
  • Optionally, the project may need to be declared a ‘ruby project’. This may already have been done. Either way, select project in navigator. Project –> Add Ruby Nature.

Use Case: Existing Eclipse Project / Existing AccuRev workspace. Already have an eclipse ruby project? Is your project already on disk in an AccuRev workspace? Then this is for you…

  • File –> Import –> General –> Existing Projects into Workspace
  • Select AccuRev workspace directory containing the Eclipse .project file
  • Checkbox the projects found then “Finish”
  • Setup AccuRev for the project with: RClick Project –> Team –> Share –> AccuRev

Test either Use Case by creating a new Ruby Class. If you don’t get any errors, so far so good. Otherwise, if the ruby nature is not set, the new class wizard will warn you when you enter the class name. Now verify the new class shows up in Team –> AccuRev Searches –> External search view. This verifies that AccuRev is connected.

I hope this batch of recipes helps you get up and running flawlessly with AccuRev + Eclipse + Ruby in no time!

For those new to Ruby+Eclipse, our friends at IBM have a great tutorial. Also, the folks at O’Reilly have a great article about using Rails+Eclipse.

/happy coding/ – dave