-
Notifications
You must be signed in to change notification settings - Fork 169
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
Conversation
plugins/webhooks/index.js
Outdated
|
||
const pipelines = await pipelineFactory.list(listConfig); | ||
|
||
const pipelinesWithSubscribedExtRepos = await pipelineFactory.list(externalRepoSearchConfig); |
There was a problem hiding this comment.
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
plugins/webhooks/index.js
Outdated
@@ -385,6 +394,15 @@ async function createPREvents(options, request) { | |||
chainPR | |||
}); | |||
|
|||
let subscribedEvent = false; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
9c6d349
to
4eca0cc
Compare
2cdec45
to
3d784f8
Compare
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 |
There was a problem hiding this comment.
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'
?
There was a problem hiding this comment.
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
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.