Setup Github Webhook for AWS EC2 server - github

I have a webapp deployed in aws ec2 instance. I recently got to know about Github Webhook. Now i am trying to setup webhook service for my ec2 server. Can someone pls give a walk-through about:
1. How to receive the webhook payload for server endpoint.
2. What will be the Payload URL that one have to write in github webhook service.

First you need to go to your repo, and click through this sequence:
Settings -> Webhooks & Services -> Add webhook
Then paste the url where github will submit data for each new commit. You can find examples of payload in example.
Then implement the logic needed in the backend to work with info about new commits.

Related

How to trigger my "Incoming Webhook" Service Connection in Azure DevOps (OnPremise)? The Endpoint URL is unknown

Overview: I try to trigger an Azure DevOps 2020 Pipeline (YAML) in the event that a WorkItem of a specific type is created. So my idea I had was to create a connection between "WorkItem" -> Service Hook of Type "Web Hook" -> Service Connection of Type "Incoming Webhook" -> resource:webhook triggers the Pipeline in YAML.
My problem now is, that I could create the serviceendpoint by GUI or by API, but the documentation and the created endpoint does not make sense for me. I am running my server on-premise and the endpoint I got looks like this:
{"count":1,"value":[{"data":{},"id":"1babbef7-1edb-4b01-bf18-b6e3c309caae","name":"TestIncomingWebhook","type":"incomingwebhook","url":"https://dev.azure.com", ...
The url does not make sense to me.
I can alter the url if I use the REST API to create the endpoint by using this format
POST https://{instance}/{collection}/{project}/_apis/serviceendpoint/endpoints
as described in Microsoft Azure API Documentation.
Questions:
Why is the url that the service connection gets pointed to https://dev.azure.com while I am running on-premise from a server on a totally different url? Would that be the url I have to POST to trigger the ServiceConnection?
What must be the correct URL-Format for my local Server? Where should I point that URL to?
How can I trigger the Service Connection from curl? Do I have to use GET with a lot of parameters or POST with a JSON payload?
I would appreciate if someone could help me out on this. Perhaps someone even got a full solution on how to trigger pipelines on workitem events. I searched a lot but could not find a solution, yet.
Thanks, Peter.
I created the WebHook and ServiceConnection from the GUI like this:
WebHook Configuration Screenshot
ServiceHook Configuration Screenshot
My real problem is, that I got no feedback what the correct ServiceHook URL is. I have no idea where to point my WebHook.
Addition:
The correct URL for accessing the Incoming Webhook Service Endpoint in Azure DevOps is https://{instance}/{Collection name}/_apis/public/distributedtask/webhooks/{Service Connection name}?api-version=6.0-preview
This should be related to your machine settings, you could share the detail steps here
Since you are using Azure DevOps Server 2020, the url format for your local Server should be https://{instance}. You could open Azure DevOps Server Administration Console to check it.
It will trigger the webhook via the event you selected.
You could refer to this ticket for more details.
In addition, you could try this Logic Apps then create flow to trigger build when specific type is created
Update1
Create Service connection Incoming WebHook, eg. Web Hooks name is HookTests and Service connection name is TestHook
Create Web Hooks and enter the URL https://{instance}/{Collection name}/_apis/public/distributedtask/webhooks/{Web Hook name eg. HookTests}?api-version=6.0-preview
Create YAML build and add service connection resources in the yaml pipeline see below:
resources:
webhooks:
- webhook: MyWebhookTrigger
connection: {Service connection name, eg.TestHook}
Above steps actually do below things:
New workitem is created-->automatically Trigger Azure pipeline.
In addition, we could also add task power shell and call REST API to trigger another pipeline.

How to create GitHub Enterprise Server - service connection In Azure DevOps using rest api?

I want to create GitHub Enterprise Service - service connection using azure DevOps rest api.
I found this rest api in Microsoft Docs -
POST https://dev.azure.com/{organization}/_apis/serviceendpoint/endpoints?api-version=6.0-preview.4
When I create service connection manually It asks me for url , connection name and GitHub token
How Can I pass this in json ?
What Json Data do I need to use for creating service connection ?
You could capture the request body by pressing F12 while you manually create GitHub Enterprise Server service connection. After pressing "Verify and save", it's supposed to get the request body under Network tab. Check my following screenshots, I have circled the useful part:

How do I specify a reply URL using AKS and AAD integration?

I have a Kubernetes (AKS) setup with AAD integration, (there is a server application and client application). When I call kubectl, aauthentication pop up and after confirmed grant to the client app, it shows an error that the reply URL is missing.
How do I pick a reply URL in AAD application registration?
I found the issue. There is no need to specify a reply URL.
I use a script to request resources, but I need a manual step to grant these requests on the portal.
You may have missed any step as documented in AKS AAD Integration.

Github with opswork auto deployment using webhook help needed

Again i got stuck to achive the target to trigger deployment once code is pushed to repo, I search the net but i found only old information github is updated and as per there instruction i setup all values but still not working so its look i am missing something I tried to follow the instruction but it seems old http://bytes.babbel.com/en/articles/2014-01-22-github-service-hook-for-aws-ops-works.html
The interface is confusing and i am confused because there is no connection between repo name and opswork service , so what value webhook should send to opswork service ?
Below is what i understood
Setup webhook and it will trigger and send pay load to CI or services as needed once code is pushed to repo (this part is working and send payload to some where) : But this is failing because its Payload URL should i give the opswork service url generated by git hub ?
Opswork services : This is not working ,
App
Given from AWS opswork's app : opswork ID
Stack
Given from AWS opswork's stack: opswork ID
Branch name
Here is the confussion again as per github help i need to give the SHA configured for that app in the AWS OpsWorks Console ? Why should i give SHA not the Master or the link of repo ?
GitHub api url
This is optional what should i give here ?
Aws access key
No issues
Aws secret access key
No issues
GitHub token
Optional : Created token as instructed , Both with token and without token not working.
So If you check opswork is not getting triggered , I thought when i push the changes it may work internally but not.
So its seems web hook and opswork service need to be interact at some level but unable to figure it out :(
I checked git hub help also found nothing for new interface
I checked google and stackoverflow too , but not found any thing
Kindly anyone please answer .
One alternative way would be to set up AWS CodePipeline (CodeDeploy??) to deploy to your AWS Opsworks stack.
CodePipeline is a Continuous Delivery solution from Amazon. Mid 2016 they announced that CodePipeline works with OpsWorks - see their blog announcement: AWS CodePipeline Adds Integration with AWS OpsWorks. There's some walkthroughs there too, depending on what version of OpsWorks your stack is set up for.
(It does feel a bit weird to use a deployment service to deploy to a service that has an existing deployment service... but eh, thought this might help)
The problem is with the process of Github and opswork , if there is any error then both do not report user with error.
I contacted to Github support and luckily they responded me back with error message "The security token included in the request is invalid."
Then i recopied the access key and secret key removed "GitHub api url" as blank and branch name to "master" (so it will always deploy the latest version aka head)
Also make sure you need to set permission again in opswork this is separate to IAM permission ,
Steps -> Goto your stack - Permission and edit -> add user github with permission "IAM Policies Only".
There is no interaction between web hooks and integrations . so you can make use of integration services without web hook :) .
Thanks to Stack overflow , Git-hub both :)

Azure Push Notification REST No Service is Hosted at the Specified Address

I am using Azure mobile services to do Push Notifications. I have a push notification service bus created. When I try to connect to that through a REST service I get the following response:
404No service is hosted at the specified address. TrackingId:dfc9aea1-e229-4eb7-b393-c8cd6bce258d_G19,TimeStamp:11/3/2014 8:39:21 PM
The POSTMAN request looks like so which duplicates the problem:
How do I further troubleshoot this because the service is there? What am I missing?
A reference to the above API can be found here:
http://msdn.microsoft.com/en-us/library/azure/dn223266.aspx
After troubleshooting with Microsoft we found the problem to be two-fold.
The Connection String key you should be using is found on the hubs page. Named DefaultFullSharedAccessSignature.
The next thing is the hub name shouldn't be the namespace.
In my URIā€¦
https://qb-alphahub-ns.servicebus.windows.net/qb-alphahub-ns/messages/?api-version=2013-10
Should be
https://qb-alphahub-ns.servicebus.windows.net/qb-alphahub/messages/?api-version=2013-10
I had the exact same issue when sending requests via Python and Postman.
I tried the above solution with no luck. My issue ended up being two-fold as well:
My namespace was named the same as my notification hub. Had to rename my hub.
I had to add an extra header to the POST: "X-WNS-Type": "wns/toast"
After making the changes, my toast notifications started working with successful responses from the Notification Hub web services.