This commit is contained in:
Simon Vieille 2016-01-23 11:54:59 +01:00
parent 350af4c943
commit 2fd887d40a

View file

@ -55,7 +55,7 @@ module.exports = (robot) ->
if pv
d = deploy directory, pv, commands, target, program
res.reply d
res.send d
else
res.reply "Not a SVN or GIT repository"
catch e
@ -127,14 +127,26 @@ deploy = (directory, projectVersionning, commands, target, program) ->
output = ""
for stmt in results
status = if stmt.status == 0 then 'OK' else 'KO'
output += "`#{stmt.command}` is *#{status}*\n"
if stmt.status != 0
output += "\n```#{stmt.stdout} #{stmt.stderr}```"
output += generateOutput stmt
output
generateOutput = (stmt) ->
prefix = "deploy-" + Date.now()
status =
if stmt.status == 0
"<span color='green'>OK</span>"
else
"<span color='red'>Failed</span>"
"""
<p><pre>#{stmt.command}</pre> #{status}</p>
<div>
Outputs: <a href="#" onclick="var e = document.getElementById('#{prefix}-stdout'); if (e.getAttribute('data-show') == 0) {e.style.display = 'block'; e.setAttribute('data-show', '1');} else {e.display = 'none'; e.setAttribute('data-show', '0');}">STDOUT</a> <a href="#" onclick="var e = document.getElementById('#{prefix}-stderr'); if (e.getAttribute('data-show') == 0) {e.style.display = 'block'; e.setAttribute('data-show', '1');} else {e.display = 'none'; e.setAttribute('data-show', '0');}">STDERR</a>
<pre id="#{prefix}-stdout" data-show="0" style="display: none">#{stmt.stdout}</pre>
<pre id="#{prefix}-stderr" data-show="0" style="display: none">#{stmt.stderr}</pre>
</div>
"""
buildDeployCommand = (directory, program, target) ->
if program == 'mage'