Skip to content

Commit

Permalink
feat(1415): Add logic to handle webhook events from external repos (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
supra08 committed Oct 13, 2020
1 parent 776384e commit 0933d72
Show file tree
Hide file tree
Showing 5 changed files with 309 additions and 82 deletions.
9 changes: 4 additions & 5 deletions plugins/pipelines/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,17 @@ module.exports = () => ({
});
}

const results = await Promise.all([
pipeline.sync(),
pipeline.addWebhooks(`${request.server.info.uri}/v4/webhooks`)
]);
const results = await pipeline.sync();

await pipeline.addWebhooks(`${request.server.info.uri}/v4/webhooks`);

const location = urlLib.format({
host: request.headers.host,
port: request.headers.port,
protocol: request.server.info.protocol,
pathname: `${request.path}/${pipeline.id}`
});
const data = await results[0].toJson();
const data = await results.toJson();

return h
.response(data)
Expand Down
20 changes: 9 additions & 11 deletions plugins/pipelines/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,15 @@ module.exports = () => ({
oldPipeline.name = scmRepo.name;

// update pipeline with new scmRepo and branch
return oldPipeline
.update()
.then(updatedPipeline =>
Promise.all([
updatedPipeline.sync(),
updatedPipeline.addWebhooks(
`${request.server.info.uri}/v4/webhooks`
)
])
)
.then(results => h.response(results[0].toJson()).code(200));
return oldPipeline.update().then(async updatedPipeline => {
await updatedPipeline.addWebhooks(
`${request.server.info.uri}/v4/webhooks`
);

const result = await updatedPipeline.sync();

return h.response(result.toJson()).code(200);
});
})
)
);
Expand Down
Loading

0 comments on commit 0933d72

Please sign in to comment.