August 14, 2013

Controlling the Buzz in Swarm

Helix Swarm
Traceability

swarm bee

 

In my last article we covered how you can have any tool in your production pipeline add events to the Swarm activity feed. However sometimes you have the opposite issue; you need to prevent events from showing up in the activity stream. A common use case for filtering out events is to prevent automated processes from flooding the activity stream.

Swarm has a couple ways to filter events. The easiest by far is to add a user to the 'ignored_users' list in Swarm. There is a configuration parameter in Swarm that allows you to specify users you never want to see activity for. For example, Swarm ships with the Git Fusion user filtered out, but you can add your own users as well. In your Swarm installation find your config.php file in data directory and include the following block:

'activity' => array(
 'ignored_users' => array('some-noisy-user')
 ),

Just add the Perforce user you want to ignore to the array. For example if I have a daemon that compiles a set of web pages from a template language into their final form I could exclude that user by setting:

'activity' => array(
 'ignored_users' => array('web_daemon')
 ),

If you need to reject events based on criteria other than user name you are going to need to build a Swarm module using PHP. Fear not; you don't need to understand the entirety of Zend Framework 2 to build a filtering module. The sample code for filtering activity is in our Public Depot and is well commented. The module you create will be called after an event is put into the event processing queue, but before it is stored and displayed to users. Your code can inspect the contents of the event and stop its propagation if it meets your criteria.

Sound useful? Head on over to the Public Depot and grab the source. If you have any questions about modifying Swarm or have a Swarm hacking article idea, the Swarm development team and myself are always available in the Perforce Forums or you can track me down on Twitter.