Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
c580b78
add deploy hook
ProZachJ Aug 9, 2014
ee51fa8
try to add deploy exit code
ProZachJ Aug 9, 2014
114c0e6
try to add deploy exit code
ProZachJ Aug 9, 2014
23c5ec0
add deploy exit code
ProZachJ Aug 9, 2014
42230f2
add output for debugging
ProZachJ Aug 9, 2014
1dd82bc
add logs
ProZachJ Aug 9, 2014
732c935
more hacking
ProZachJ Aug 9, 2014
7978f01
remove logline
ProZachJ Aug 9, 2014
4954f7e
make exitcode dynamic
ProZachJ Aug 9, 2014
2a7aaca
Improve deploy logic
ProZachJ Aug 9, 2014
6cd19d8
remove deploy exit code
ProZachJ Aug 9, 2014
e5f9b1f
fix logic
ProZachJ Aug 9, 2014
5104d89
improve logic
ProZachJ Aug 9, 2014
db2dea3
remove logic
ProZachJ Aug 9, 2014
2a01d08
logic gah
ProZachJ Aug 9, 2014
a4c8d84
trying to fix
ProZachJ Aug 9, 2014
9b51c2c
I sux
ProZachJ Aug 9, 2014
d2b859a
Refactor hook callbacks
ProZachJ Aug 10, 2014
48804b1
describe which hook is firing in output
ProZachJ Aug 10, 2014
80b81de
bring listeners onto scope
ProZachJ Aug 10, 2014
f719e82
move deployed on io scope
Aug 10, 2014
f9d245d
remove unneeded function
Aug 10, 2014
a2690f1
Remove logline
ProZachJ Aug 10, 2014
69dfece
add triggers input
Aug 10, 2014
9e2b2ea
add triggers input
Aug 10, 2014
d126b0e
add trigger heading
Aug 10, 2014
fb857c5
add trigger heading
Aug 10, 2014
7fc137b
widen span
Aug 10, 2014
7f970de
move paragraph to keep table from blowing out background
Aug 10, 2014
cb07912
move well style onto fieldset
Aug 10, 2014
f6f4b45
adjust margin
Aug 10, 2014
59eb646
move well
Aug 10, 2014
db6e770
remove extra equals
Aug 10, 2014
1311f8e
remove extra div
Aug 10, 2014
9fda18d
try to contain fieldset
Aug 10, 2014
9d5e346
try to contain table width
Aug 10, 2014
1f8509a
remove unneeded div
Aug 10, 2014
454b4c7
add radio buttons
Aug 10, 2014
213189b
make remove button smaller
Aug 10, 2014
e196fc5
trying a dropdown
Aug 10, 2014
b77a97d
adjust max width of field
Aug 10, 2014
a08cc25
adjust max width of field
Aug 10, 2014
a2a3a2f
playing with the form
Aug 10, 2014
1b6be53
try form with no table
Aug 10, 2014
72f88ab
modify css
Aug 10, 2014
604490a
trying to understand why bootstrap is not inlining
Aug 10, 2014
aef361d
another inline form attempt
Aug 10, 2014
620cfa3
more style changes
Aug 10, 2014
2589d8b
close td
Aug 10, 2014
0e43845
more td
Aug 10, 2014
6a41da7
add spaces
Aug 10, 2014
a0c6bd7
Try to make radios exclusive
Aug 10, 2014
4c11c91
fixing radios
Aug 10, 2014
e9e4d31
add model
Aug 10, 2014
355987b
provide control into hook listener functions
Aug 10, 2014
63d36d4
debug add log
Aug 10, 2014
4cf3886
add model binding to trigger
Aug 10, 2014
b7ca04c
deregister all listeners
Aug 10, 2014
f77902b
seperate listener functions
Aug 10, 2014
587f8e9
add logic for registering deploy listener only on deployable jobs
Aug 10, 2014
f2552f9
make input names dynamic
Aug 10, 2014
720bad4
edit repeater
Aug 10, 2014
553483b
edit repeater
Aug 10, 2014
3494da1
Merge pull request #2 from ProZachJ/triggers
ProZachJ Aug 10, 2014
4339003
move payload into repeater
Aug 10, 2014
3353a9d
add tr
Aug 10, 2014
d015949
nest table
Aug 10, 2014
dd134d1
add break
Aug 10, 2014
edb8161
add repeat-end
Aug 10, 2014
885c03b
add empty tr as end
Aug 10, 2014
bae5201
Merge pull request #3 from ProZachJ/reallyfixform
ProZachJ Aug 13, 2014
0ae6b93
merge in master
Aug 13, 2014
d62a842
merge upstream master
Aug 13, 2014
029ace9
move listener removal from forEach
Aug 14, 2014
a5cd3aa
refactor deploy listener registration and removal
Aug 14, 2014
dd80c2b
debugging
Aug 14, 2014
116a5cc
more debug
Aug 14, 2014
a6a790c
bring deploy listener removal back in.
Aug 14, 2014
16dbf0c
add log jobtype
Aug 14, 2014
7fc4095
fix conditional assignment
Aug 14, 2014
e84a918
uncomment listener removal.
Aug 14, 2014
0d2566b
uncomment listener addition
Aug 14, 2014
ab54857
more debug
Aug 14, 2014
f6d9fec
remove logging
Aug 14, 2014
d5122ef
Merge pull request #5 from ProZachJ/refactordeploy
ProZachJ Aug 14, 2014
7ead023
add comments
Aug 14, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 44 additions & 34 deletions config/config.html
Original file line number Diff line number Diff line change
@@ -1,53 +1,63 @@
<div id="project_config_webhooks" class="well">
<div id="project_config_webhooks" class="tab-pane well">
<fieldset>
<legend>Webhooks</legend>
<div class="alert alert-success hide"></div>
<p>
Target URLs will receive a HTTP POST from Strider
with a JSON payload on each project test run. These
enable you to receive and process real-time push
notifications from our system. Push notifications
are signed cryptographically with HMAC-SHA1 using a
shared secret so you can verify their
authenticity. Signatures are transmitted in
the
<a href="http://pubsubhubbub.googlecode.com/svn/trunk/pubsubhubbub-core-0.3.html#authednotify">
X-Signature-Hub header.
</a>
<a href="https://gist.github.com/3029840">See a sample payload.</a>
</p>
<div class="row-fluid">
<div class="span9">
Target URLs will receive a HTTP POST from Strider
with a JSON payload on each project test run. These
enable you to receive and process real-time push
notifications from our system. Push notifications
are signed cryptographically with HMAC-SHA1 using a
shared secret so you can verify their
authenticity. Signatures are transmitted in
the
<a href="http://pubsubhubbub.googlecode.com/svn/trunk/pubsubhubbub-core-0.3.html#authednotify">
X-Signature-Hub header.
</a>
<a href="https://gist.github.com/3029840">See a sample payload.</a>
</p>
<table class="table">
<thead>
<th>Hook Title</th>
<th>TargetURL for HTTP Post</th>
<th>Shared secret for HMAC-SHA1 signature</th>
<th>Hook Trigger</th>
<th>Delete</th>
</thead>
<tbody>

<tr ng-repeat-start="hook in hooks">
<td><input ng-model="hook.title"></td>
<td><input ng-model="hook.url"</td>
<td><input ng-model="hook.secret"></td>
<td class="remove">
<button class="btn btn-danger" ng-disabled="saving" ng-click="remove(hook)">
<i class="icon-remove"></i>
</button>
</td>
</tr>
<tr ng-repeat-end>
<td colspan="4">
<textarea
placeholder="You can put a custom payload format here"
ng-model="hook.format">
</textarea>
</td>
<form class="form-inline">
<td><input type="text" ng-model="hook.title"></td>
<td><input type="text" ng-model="hook.url"></td>
<td><input type="text" ng-model="hook.secret"></td>
<td>
<label class="radio inline">
<input type="radio" value="test" ng-model="hook.trigger">&nbsp;Test&nbsp;&nbsp;
</label>
<label class="radio inline">
<input type="radio" value="deploy" ng-model="hook.trigger">&nbsp;Deploy&nbsp;&nbsp;
</label>
</td>
<td>
<button class="btn-sm btn-danger" ng-disabled="saving" ng-click="remove(hook)">
<i class="icon-remove"></i>
</button>
</td>
<tr>
<td colspan="4">
<textarea
placeholder="You can put a custom payload format here"
ng-model="hook.format">
</textarea>
</td>
</tr>
</form>
</tr>
<tr ng-repeat-end></tr>
</tbody>
</table>
<button class="btn btn-success" ng-click="add()" ng-disabled="saving">Add</button>
<button class="btn" ng-click="save()" ng-disabled="saving">Save Hooks</button>
</div>
</div>
</fieldset>
</div>
2 changes: 2 additions & 0 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ app.controller('WebhooksCtrl', ['$scope', function ($scope) {
function remove(ar, item) {
ar.splice(ar.indexOf(item), 1);
}

$scope.hooks = $scope.pluginConfig('webhooks') || [];

if (!Array.isArray($scope.hooks)) $scope.hooks = [];
if (!$scope.hooks.length) $scope.hooks.push({});

Expand Down
19 changes: 13 additions & 6 deletions config/config.less
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@

#project_config_webhooks {
.input-append {
input {
display: block;
width: 100%;
}
}

textarea {
width: 100%;
box-sizing: border-box;
}

table {
width: 100%;
}

fieldset {
max-width: 970px;
}

.icon-remove {
padding-left: 0px;
padding-right: 0px;
}
}
51 changes: 40 additions & 11 deletions worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,50 @@ module.exports = {
var hooks = utils.makeWebHooks(config || [], job)
cb(null, {
listen: function (io, context) {
function onTested(id, data) {
io.removeListener('job.status.tested', onTested)
io.on('job.status.tested', onTested)

// add deploy listener if job will be deploying
if(job.type === 'TEST_AND_DEPLOY'){
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only register the deploy listener if the job is going to deploy.

io.on('job.status.deployed', onDeployed)
}

function onTested (id, data){
hooks.forEach(function (hook) {
context.comment('Firing webhook ' + hook.title)
try {
var payload = hook.prepare(data, job)
io.emit('plugin.webhooks.fire', hook.url, hook.secret, payload)
} catch (e) {
context.comment('Failed to prepare webhook payload: ' + e.message);
return
if(hook.trigger === 'test'){
context.comment('Firing Test webhook ' + hook.title)
try {
var payload = hook.prepare(data, job)
io.emit('plugin.webhooks.fire', hook.url, hook.secret, payload)
} catch (e) {
context.comment('Failed to prepare webhook payload: ' + e.message);
}
}
});
//always remove test listener
io.removeListener('job.status.tested', onTested);
//remove deploy listener if tests failed and one was registered
if (data.exitCode !== 0 && job.type === 'TEST_AND_DEPLOY'){
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the tests failed and a deploy listener was registered we need to remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you put these notes in as comments?

io.removeListener('job.status.deployed', onDeployed);
}
}

function onDeployed (id, data){
hooks.forEach(function (hook) {
if(hook.trigger === 'deploy'){
context.comment('Firing Deploy webhook ' + hook.title)
try {
var payload = hook.prepare(data, job)
payload['deploy_exitcode'] = (data.exitCode === 0) ? 0 : 1
io.emit('plugin.webhooks.fire', hook.url, hook.secret, payload)
} catch (e) {
context.comment('Failed to prepare webhook payload: ' + e.message);
}
}
})
//always remove deploy listener
io.removeListener('job.status.deployed', onDeployed);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if onDeployed is called remove listener after firing hooks

}
io.on('job.status.tested', onTested)
}
})
},
}
}