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

Can the slack summary be sent to a generic webhook URL endpoint? #3347

Open
kmaqsudi opened this issue Apr 14, 2021 · 22 comments
Open

Can the slack summary be sent to a generic webhook URL endpoint? #3347

kmaqsudi opened this issue Apr 14, 2021 · 22 comments

Comments

@kmaqsudi
Copy link

is it possible to send the slack summary to a generic webhook such as the public URL provided by microsoft teams?

@soulgalore
Copy link
Member

Hi @kmaqsudi we need to create a new plugin for that, but it should not be too hard. Checkout the Matrix plugin that I guess have most functionality that is needed: https://github.com/sitespeedio/sitespeed.io/tree/main/lib/plugins/matrix

Do you have time @kmaqsudi to give It a try? I can help guide you.

@kmaqsudi
Copy link
Author

kmaqsudi commented Apr 14, 2021 via email

@kmaqsudi
Copy link
Author

was not able to get it working

@ganeshcpote
Copy link

Is there any blog available to use custom generic webhook endpoint?

@soulgalore
Copy link
Member

@kmaqsudi let me have a go tomorrow. I'll start with a simple example and then maybe you can verify that it works for you and then we can add more functionality? For my use case I need only the URL of the result.

@soulgalore
Copy link
Member

@ganeshcpote You mean blog how to use it from sitespeed.io? No not right now, but let me give it a try to see if I can add the functionality first and then some documentation.

@kmaqsudi
Copy link
Author

kmaqsudi commented May 3, 2021 via email

@kmaqsudi
Copy link
Author

kmaqsudi commented May 4, 2021

@soulgalore for reference, this is what i'm trying to have the output of the sitespeed jobs go to with a link to the summary (same as what you do today for slack).

https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using

@ganeshcpote
Copy link

@ganeshcpote You mean blog how to use it from sitespeed.io? No not right now, but let me give it a try to see if I can add the functionality first and then some documentation.

Thanks @soulgalore .. I will wait for your response since this is something very interesting and want to use this for my most of the use cases

@soulgalore
Copy link
Member

Hi @kmaqsudi is it easy for you to test a branch? https://github.com/sitespeedio/sitespeed.io/tree/webhook ?

I've made it as simple as possible for now and I've only tested it with https://requestbin.net

I've tested it like this:
bin/sitespeed.js --webhook.url http://requestbin.net/r/ffx4mgqy https://www.sitespeed.io -n 1 --resultBaseURL https://myfiles.com/
It will post a JSON that looks like {"text": "url"} and you can your own parameters like this:
bin/sitespeed.js --webhook.url http://requestbin.net/r/ffx4mgqy --webhook.secret "my secret" https://www.sitespeed.io -n 1 --resultBaseURL https://myfiles.com/

and the post will be:
{"text": "url", "secret": "my secret"}

Let me know how it works out for you + what's the best formatting, is it markdown?

@ganeshcpote
Copy link

Hi @soulgalore, is this webhook feature released for use?

@soulgalore
Copy link
Member

No @ganeshcpote I need someone to try it first.

@ganeshcpote
Copy link

ganeshcpote commented May 18, 2021

Hi @soulgalore, where do I find the docker container image for this webhook branch? I want to try this tomorrow with some of the use cases I have on this.

@soulgalore
Copy link
Member

Hi @ganeshcpote , cool, we auto build every branch so you can try the container: sitespeedio/sitespeed.io-autobuild:webhook

@ganeshcpote
Copy link

ganeshcpote commented May 19, 2021

Hi @ganeshcpote , cool, we auto build every branch so you can try the container: sitespeedio/sitespeed.io-autobuild:webhook

Hi @soulgalore, I was trying with my Jenkins generic webhook and it looks like port number is hardcoded in the file https://github.com/sitespeedio/sitespeed.io/blob/webhook/lib/plugins/webhook/send.js (line no: 13). We need to change the logic to get it from URL instead of. I will try with https://requestbin.net and post you the response

image

@ganeshcpote
Copy link

Hi @soulgalore, I was able to successfully test this feature which sent the report URL through webhook.

Is there any chance to optimize this feature to include the following :

  • port number to be parameterized
  • send json formatted report to webhook (as additional storage if someone wants to read the json and store in their own database)

@soulgalore
Copy link
Member

Hi @ganeshcpote I've fixed the port so it takes it from the URL, it will take X minutes before the container is rebuilt.

About what to send: not sure about what to send, but at least I should start by doing it configurable so you can choose. Lets see if I can find some time this weekend to start doing that.

@kmaqsudi
Copy link
Author

kmaqsudi commented May 21, 2021 via email

@soulgalore
Copy link
Member

So I got stuck with this. I'm working on branch where you can configure if the message will be HTML/Markdown or plain text. I hope to be able to push that late this week.

@kmaqsudi
Copy link
Author

kmaqsudi commented Jun 15, 2021 via email

@soulgalore
Copy link
Member

I pushed a couple of changes today and it would be great if someone can help me try them out and fine-tune the output. I tried first using pug to generate different output (html/markdown/text) to separate the code from the look but no luck.

I used https://webhook.site to try it out it would be great to test them in a real env. I haven't tested all different usecases yet so there are a lot that can be tuned.

Either you checkout the branch webhook and run directly from there:
bin/sitespeed.js https://www.sitespeed.io --webhook.url https://webhook.site/XXXXXXX -n 1 --headless --webhook.messages pageSummary --webhook.style markdown

Or if you use Docker use the container:
sitespeedio/sitespeed.io-autobuild:webhook

You can choose when to send a message:

  • on errors - if something goes wrong in your test
  • budget - the budget result
  • pageSummary - when a page has finished testing. To get a good feel of what it would like you should also set resultBaseURL,

I only did minima<l styling with markdown and HTML so please feel free to fix what's broken and send PRs to that branch I'll merge them ASAP.

@soulgalore soulgalore removed the prio:3 label Feb 12, 2022
@soulgalore
Copy link
Member

I totally forgot about this. I updated the branch and made a PR in #4045

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants