~russell/ibid/jira-plugin

« back to all changes in this revision

Viewing changes to ibid/plugins/buildbot.py

  • Committer: Michael Gorven
  • Date: 2009-01-29 08:55:18 UTC
  • Revision ID: michael@gorven.za.net-20090129085518-sk9sh4scr8sr5two
buildbot: Add command to trigger builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from twisted.spread import pb
 
2
from twisted.internet import reactor
 
3
from twisted.cred import credentials
 
4
 
1
5
import ibid
2
 
from ibid.plugins import Processor, RPC
 
6
from ibid.plugins import Processor, match, RPC
3
7
 
4
8
help = {}
5
9
 
6
10
class BuildBot(Processor, RPC):
7
11
 
8
12
    feature = 'buildbot'
 
13
    server = 'localhost'
 
14
    port = 9989
9
15
 
10
16
    def __init__(self, name):
11
17
        Processor.__init__(self, name)
15
21
        reply = u"Build %s of %s triggered by %s: %s" % (revision, branch, person, result)
16
22
        ibid.dispatcher.send({'reply': reply, 'source': self.source, 'target': self.channel})
17
23
 
 
24
    @match(r'^build\s+(.+?)(?:\s+(?:revision|r)?\s*(\d+))?$')
 
25
    def build(self, event, branch, revision):
 
26
        change = {  'who': event.who,
 
27
                    'branch': branch,
 
28
                    'files': [None],
 
29
                    'revision': revision or '-1',
 
30
                    'comments': 'Rebuild',
 
31
                }
 
32
 
 
33
        buildbot = pb.PBClientFactory()
 
34
        reactor.connectTCP(self.server, self.port, buildbot)
 
35
        d = buildbot.login(credentials.UsernamePassword('change', 'changepw'))
 
36
        d.addCallback(lambda root: root.callRemote('addChange', change))
 
37
        d.addCallback(self.respond, event, True)
 
38
        d.addErrback(self.respond, event, False)
 
39
        event.processed = True
 
40
 
 
41
    def respond(self, foo, event, result):
 
42
        print foo
 
43
        ibid.dispatcher.send({'reply': result and 'Okay' or u"buildbot doesn't want to build :-(", 'source': event.source, 'target': event.channel})
 
44
                    
 
45
 
18
46
# vi: set et sta sw=4 ts=4: