My favorites | Sign in
Project Logo
                
Search
for
Updated Jul 30, 2007 by swing1979
Labels: Featured
CCMonitor06  

version 0.6

new features:

Preview

Notes

I tested it on cc.rb, so if you use it monitoring another CC, you need to make sure that RSS item title includes 'success', 'passed' or 'fixed' for build success(I checked cruisecontrol's source code, that should work, but I didn't test it or maybe the early version was different). Otherwise, you need to overwrite the success method of build object in configuration(it's easy, take a look at example of configuration file bellow).

I will release new version once I fixed bugs or added new features. It will be great that you report the bugs or problems you got. I'll fix them and give you response as quickly as possible.

Make it work

  • Download and install it as Dashboard widget.
  • Create your project configuration which should be a JSON format file. The following is an example(just like a javascript file :):
  • {
    	projects: [
    		{
    			'name': 'project1', 
    			'source': 'http://ccServer/projects/project1.rss',
                            // Sometimes, the committer name does not make sense, you can redefine by a users map. 
                            // Then you can get committers which is a useful message sometime from build object as you wish.
    			users: {
    				'xli': 'li xiao'
    			}
    		}, 
    		{
    			'name': 'project2', 
    			'source': 'http://ccServer/projects/project2.rss',
    			// you can redefine the implementation of build object		
    			// build: 
    			//    > success, which should return true if build succeeded. 
    			//    > committers, which is parsed from rss description by regex '/committed by (\w+)/'. 
                            //      If it does not work this way, rewrite it for yourself.
    			//    > link, which can been open in browser.
                            //    > notify(observer), you can renotify an observer
                            // build object has the following fields:
                            //    > rssItem, it is parsed from RSS and has title, description and link
                            //    > isNew, which means the build is just finished, we should report it.
                            //    > monitor, which is the object of project build monitor.
                            //    > name, which is the name of project defined in this file.
                            //    > users, it should be {} if you didn't define it in this file. 
    			build: {
    		          success: function() {
                                return /(SUCCESS|FIXED|PASSED)/.test(this.rssItem.title().toUpperCase());
                              }
    			}
    		}
    	],
    	// add observers here, you should config at least one observer, otherwise you will not know what happened.
    	observers: [ new BgImgView(), new StatusBarIconView(), new SpeakerObserver(), new GrowlNotification() ]
    }
  • Make sure the assertion of build success work well with your cc, it is: '/(SUCCESS|FIXED|PASSED)/.test(this.rssItem.title().toUpperCase())' now. You can overwrite it in configuration file if it does not work, see the example of configuration above.

Observers

  • Build-in observers:
    • BgImgView: It will change the background img of widget panel to green/red after build succeeded or failed.
    • StatusBarIconView: It displays one icon on status panel for one build. It's good for monitoring more than 3 builds.
    • StatusBarTextView: It displays text message after get build result. For the panel of widget is small, it does not fit for displaying more than 3 builds result.
    • SpeakerObserver: it will say 'project build succeeded/failed, committed by xxx, yyy and zzz'.
    • GrowlNotification: it will send a notification to Growl Application when build success/failed. I made mistake of spelling 'Notification', it was "GrowlNotifaction" before version0.5.
  • Interface of observer(built by prototype style):
  • BuildObserver = Class.create();
    BuildObserver.prototype = {
      initialize: function() {},
      // fired after all projects have been observed
      onEnd: function(monitors) {},
      // fired when load project build rss item failed
      onError: function(build) {},
      // fired when project build failed
      onFailure: function(build) {},
      // fired when there is no new build of project
      onSkip: function(build) {},
      // fired before start to observe projects
      onStart: function(monitors) {},
      // fired when project build succeeded
      onSuccess: function(build) {},
      // It will be invoked by Build object. Build observer must have notify method.
      notify: function(eventName, arg) {
        if(typeof(this[eventName]) == 'function') {
          this[eventName](arg);
        }
      }
    }
  • Example(It'll be better that you always extend from a new BuildObserver object to build your own):
  • SpeakerObserver = Class.create();
    SpeakerObserver.prototype = Object.extend(new BuildObserver(), {
    	onSuccess: function(build) {
    		this.say('Wohoo! ' + build.monitor.name + ' build succeeded, ' + build.committers());
    	},
    
    	onFailure: function(build) {
    		this.say(build.monitor.name + ' build failed, ' + build.committers());
    	},
    
    	say: function(str) {
    		if(window.widget) {
    			command = '/usr/bin/osascript -e 'say \'' + str + '\'''
    			window.widget.system(command, null);
    		}else {
    			alert(str);
    		}
    	}
    });

Sign in to add a comment
Hosted by Google Code