Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(1415): Add logic to handle webhook events from external repos #2187

Merged
merged 20 commits into from
Oct 13, 2020

Conversation

supra08
Copy link
Contributor

@supra08 supra08 commented Aug 21, 2020

Context

Fixes #1415

Objective

This PR adds logic to webhook endpoint to handle notifications from external repos. First it filters the triggered pipelines with the checkoutUrl from the incoming request. Here it utilizes the newly added contains operator for querying. After that it is checked whether the request is from an external repo or not and based on that sends a flag to the EventFactory module to handle them likewise.

References

#1415

License

I confirm that this contribution is made under a BSD license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@supra08 supra08 changed the title External scms feat(1415): Add logic to handle webhook events from external repos Aug 21, 2020

const pipelines = await pipelineFactory.list(listConfig);

const pipelinesWithSubscribedExtRepos = await pipelineFactory.list(externalRepoSearchConfig);
Copy link
Member

Choose a reason for hiding this comment

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

we can call this pipelinesWithSubscribedRepos

@@ -385,6 +394,15 @@ async function createPREvents(options, request) {
chainPR
});

let subscribedEvent = false;
Copy link
Member

Choose a reason for hiding this comment

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

don't you need similar changed in createEvents function ? This function is called only for PR events

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah they are coming up as further additions. This was just a work in progress.

@coveralls
Copy link

coveralls commented Aug 29, 2020

Coverage Status

Coverage decreased (-0.2%) to 95.716% when pulling f43ff92 on supra08:external-scms into 776384e on screwdriver-cd:master.

@supra08 supra08 force-pushed the external-scms branch 2 times, most recently from 9c6d349 to 4eca0cc Compare September 2, 2020 19:33
plugins/webhooks/index.js Outdated Show resolved Hide resolved
plugins/webhooks/index.js Outdated Show resolved Hide resolved
plugins/webhooks/index.js Outdated Show resolved Hide resolved
plugins/webhooks/index.js Outdated Show resolved Hide resolved
@supra08 supra08 closed this Sep 22, 2020
@supra08 supra08 reopened this Sep 22, 2020
if (b === branch) {
eventConfig.startFrom = '~pr';
}

// Check if the webhook event is from a subscribed repo and
// set the jobs entrypoint from ~startfrom
// For subscribed PR event, it should be mimiced as a commit
Copy link
Member

Choose a reason for hiding this comment

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

what does this mean? should this be type: 'pr'?

Copy link
Member

Choose a reason for hiding this comment

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

pr event happened on the subscribed git repo. But for the subscriber it's similar to running a commit event

@jithine jithine closed this Oct 12, 2020
@jithine jithine reopened this Oct 12, 2020
@tkyi tkyi merged commit 0933d72 into screwdriver-cd:master Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notify SCM changes from external repositories
5 participants