开发者

Checkin Notification with StarTeam

Does someone know how we can开发者_StackOverflow have Starteam send email notifications when a check in occurs? We are using Starteam 2006 R2.


Unfortunately StarTeam doesn't offer the ability to execute post-checkin actions. You may be able to use an application like Cruise Control to monitor your repository for changes and then take action upon seeing them.


I had a similar need a few months ago, this is what I discovered:

Starteam does not have commit hooks but it does have Starteam MPX (borland.com). From that link,

StarTeamMPX is a framework for publish/subscribe messaging. The StarTeamMPX Server uses an advanced caching and communication technology that both improves the performance of StarTeam clients and extends the scalability of the StarTeam Server.

Ok, so, we can subscribe to events. It's looking promising.

There is a Java API (borland.com) for Starteam, create an app using this API with your own emailing implemention of the CheckinListener interface. The app will then have to connect to Starteam, find any views that you're interested in and register listeners against them. And then wait.

Your listener will receive CheckinEvents and can interrogate these. Unfortunately, it appears to be on a file by file basis. I couldn't see anything in the API to say "commit finished", only "file finished". You are able to discover if a commit was cancelled. I don't know how easy it is to combine file checkin events back into a complete check in event.

*StarteamMPX is an extension (paid) to Starteam, it is available for 2006 R2. All of this is clearly only applicable if it is enabled.


My Experience: My company didn't have that extension enabled, and to enable it required upgrading i.e. more money. So it didn't happen (I think it's painful enough paying for Starteam to begin with). At this point I abandoned my research and none of the above was ever implemented this. I hope this is some use to someone.


I've been doing some homework into this topic too, so will share what I've learnt.

MicroFocus now offer a Notification Agent tool for this sort of thing:

http://www.youtube.com/watch?v=QTKAT-ufkIs

It's an extra you pay for though.

I've been also pondering how to "roll-your-own" via advice given in Dan's post above. Yes, MPX does seem to be the way to go, although after studying the CheckinListener, this isn't the class you're after. To clarify, CheckinListener is used by the client performing the check-in, so that it can monitor progress of the check-in (perhaps to display a progress bar, that sort of thing).

Here's some sample-code of what listening to MPX events looks like:

        Server s = new Server(strAddress, nPort);
    s.connect();
    s.enableMPX();  // must do this for MPX support
    s.logOn(strUsername, strPassword);

    Project p = s.findProject("mylovelyproject");

    View v = p.s.findView("mylovelyview");

    ItemListener listener = new ItemListener()
    {

        public void itemAdded(ItemEvent e)
        {
            System.out.println("itemAdd() - " + e.getNewItem().getComment());
        }

        public void itemMoved(ItemEvent e)
        {
            System.out.println("itemMoved() - from: " + e.getOldItem().getParentFolderHierarchy() + ", to: " + e.getNewItem().getParentFolderHierarchy());
        }

        public void itemChanged(ItemEvent e)
        {
            System.out.println("itemChanged() - " + e.getNewItem().getComment());
            System.out.println("  - from: v" + e.getOldItem().getDotNotation().toString());
            System.out.println("  - to: v" + e.getNewItem().getDotNotation().toString());
            User locker = e.getNewItem().getLocker();
            if (locker != null)
                System.out.println("  - locked by:" + locker.getDisplayName());
            else
                System.out.println("  - not locked");
        }

        public void itemRemoved(ItemEvent e)
        {
            System.out.println("itemRemoved() - " + e.toString());
        }
    };

    v.addItemListener(listener, s.getTypes().FILE);

The MPX-related items to focus on here are new ItemListener() (what to do about the events you listen to) and v.addItemListener() (which starteam view you want to listen to).

The sample code will spit out various print output to the console as files in your view are added/modified/moved/deleted.

Apart from ItemListener, you also have ViewListener and ProjectListener. Each interface provides a different scope of events to listen for, more info on this in the sdk docs, also a nice article here:

http://conferences.embarcadero.com/article/32231#MPXEventHandling

So if you want to roll-your-own notification emails, these MPX events provide part of your answer (a way to listen to these change-events).

Other aspects you'll need to look into after this are:

  • How to allow users to subscribe to various servers/projects/views, to decide what they want to listen to.

  • How to email to the user what they want (StarTeam's Server class offers a .SendMail() method, which can help here).

Once all these bases are covered, you should have something that does the trick. I'll be working on something like this myself over the coming days, I'll share what I can.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜