Skip to content

Commit

Permalink
feat(1415): Configure subscribed jobs to be triggered wrt to startFrom
Browse files Browse the repository at this point in the history
  • Loading branch information
supra08 committed Aug 28, 2020
1 parent af52ca7 commit 6b2f065
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 11 additions & 7 deletions plugins/webhooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,6 @@ async function createPREvents(options, request) {
baseBranch: branch
};

// Check is the webhook event is from a subscribed repo
if (uriTrimmer(scmConfig.scmUri) !== uriTrimmer(p.scmUri)) {
eventConfig.subscribedEvent = true;
eventConfig.subscribedScmConfig = scmConfig;
}

if (skipMessage) {
eventConfig.skipMessage = skipMessage;
}
Expand All @@ -436,6 +430,14 @@ async function createPREvents(options, request) {
eventConfig.startFrom = '~pr';
}

// Check is the webhook event is from a subscribed repo and
// set the jobs entrypoint from ~startfrom
if (uriTrimmer(scmConfig.scmUri) !== uriTrimmer(p.scmUri)) {
eventConfig.subscribedEvent = true;
eventConfig.subscribedScmConfig = scmConfig;
eventConfig.startFrom = '~subscribe';
}

return eventConfig;
})
);
Expand Down Expand Up @@ -852,10 +854,12 @@ async function createEvents(
ref
};

// Check is the webhook event is from a subscribed repo
// Check is the webhook event is from a subscribed repo and
// set the jobs entry point to ~subscribe
if (uriTrimmer(scmConfigFromHook.scmUri) !== uriTrimmer(pTuple.pipeline.scmUri)) {
eventConfig.subscribedEvent = true;
eventConfig.subscribedScmConfig = scmConfigFromHook;
eventConfig.startFrom = '~subscribe';
}

if (skipMessage) {
Expand Down
4 changes: 2 additions & 2 deletions test/plugins/webhooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ describe('webhooks plugin test', () => {
scmContext,
sha,
configPipelineSha: latestSha,
startFrom: '~commit',
startFrom: '~subscribe',
baseBranch: 'master',
causeMessage: `Merged by ${username}`,
changedFiles,
Expand Down Expand Up @@ -1894,7 +1894,7 @@ describe('webhooks plugin test', () => {
scmContext,
sha,
configPipelineSha: latestSha,
startFrom: '~pr',
startFrom: '~subscribe',
prNum: 2,
prTitle: 'Update the README with new information',
prRef,
Expand Down

0 comments on commit 6b2f065

Please sign in to comment.