Last active 1440820878

Steven Smith revised this gist 1399793144. Go to revision

1 file changed, 2 insertions, 2 deletions

b3DeployListen.py

@@ -5,7 +5,7 @@ import subprocess
5 5
6 6 nick = "Nexus"
7 7 user = "Nexus"
8 - pass = "bouncer password"
8 + passw = "bouncer password"
9 9 jenkins_nick = "HawkJenkins"
10 10 jenkins_job = "Nexus"
11 11 script_path = "/home/nexus/redeploy.sh"
@@ -17,7 +17,7 @@ port = 5555 # if changed, else 6667
17 17 class Bot(irc.IRCClient):
18 18 nickname = nick
19 19 username = user
20 - password = pass
20 + password = passw
21 21
22 22 def signedOn(self):
23 23 print "Signed on as %s." % self.nickname

Steven Smith revised this gist 1399793046. Go to revision

1 file changed, 53 insertions

b3DeployListen.py(file created)

@@ -0,0 +1,53 @@
1 + from twisted.words.protocols import irc
2 + from twisted.internet import protocol, task, reactor
3 + from twisted.application import internet, service
4 + import subprocess
5 +
6 + nick = "Nexus"
7 + user = "Nexus"
8 + pass = "bouncer password"
9 + jenkins_nick = "HawkJenkins"
10 + jenkins_job = "Nexus"
11 + script_path = "/home/nexus/redeploy.sh"
12 +
13 + channel = "#DSH105" # channel script will try to join
14 + server = "bouncer.bounce" # irc server or bouncer
15 + port = 5555 # if changed, else 6667
16 +
17 + class Bot(irc.IRCClient):
18 + nickname = nick
19 + username = user
20 + password = pass
21 +
22 + def signedOn(self):
23 + print "Signed on as %s." % self.nickname
24 +
25 + def privmsg(self, user, channel, msg):
26 + nick, _, host = user.partition("!")
27 + trigger_phrase = "Project %s build" % jenkins_job
28 + if nick == jenkins_nick and trigger_phrase in msg and "SUCCESS" in msg:
29 + out = subprocess.check_output([script_path])
30 + self.msg(channel, "Starting redeploy (triggered by %s)... " % jenkins_nick + out)
31 +
32 + class BotFactory(protocol.ClientFactory):
33 + protocol = Bot
34 +
35 + def __init__(self, channel):
36 + self.channel = channel
37 +
38 + def clientConnectionLost(self, connector, reason):
39 + print "Lost connection (%s), reconnecting." % (reason,)
40 + connector.connect()
41 +
42 + def clientConnectionFailed(self, connector, reason):
43 + print "Could not connect: %s" % (reason,)
44 +
45 + if __name__ == "__main__":
46 + channel = channel
47 + reactor.connectTCP(server, port, BotFactory(channel))
48 + reactor.run()
49 + elif __name__ == '__builtin__':
50 + application = service.Application('H365IRCBot')
51 + channel = channel
52 + ircService = internet.TCPClient(server, port, BotFactory(channel))
53 + ircService.setServiceParent(application)
Newer Older