Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit ede9e5a

Browse files
committed
including information about last job.
1 parent 8df2103 commit ede9e5a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/scripts/jenkins.coffee

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,33 @@ jenkinsDescribe = (msg) ->
9090
response += "PARAMETERS: #{parameters}\n"
9191

9292
msg.send response
93+
94+
if not content.lastBuild
95+
return
96+
97+
path = "#{content.lastBuild.url}/api/json"
98+
req = msg.http(path)
99+
if process.env.HUBOT_JENKINS_AUTH
100+
auth = new Buffer(process.env.HUBOT_JENKINS_AUTH).toString('base64')
101+
req.headers Authorization: "Basic #{auth}"
102+
103+
req.header('Content-Length', 0)
104+
req.get() (err, res, body) ->
105+
if err
106+
msg.send "Jenkins says: #{err}"
107+
else
108+
response = ""
109+
try
110+
content = JSON.parse(body)
111+
console.log(JSON.stringify(content, null, 4))
112+
jobstatus = content.result || 'PENDING'
113+
jobdate = new Date(content.timestamp);
114+
response += "LAST JOB: #{jobstatus}, #{jobdate}\n"
115+
116+
msg.send response
117+
catch error
118+
msg.send error
119+
93120
catch error
94121
msg.send error
95122

0 commit comments

Comments
 (0)