-
Notifications
You must be signed in to change notification settings - Fork 7k
feat: Add Support for AzureDevops Webhooks #14969
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,27 +4,36 @@ | |
|
|
||
| Argo CD polls Git repositories every three minutes to detect changes to the manifests. To eliminate | ||
| this delay from polling, the API server can be configured to receive webhook events. Argo CD supports | ||
| Git webhook notifications from GitHub, GitLab, Bitbucket, Bitbucket Server and Gogs. The following explains how to configure | ||
| Git webhook notifications from GitHub, GitLab, Bitbucket, Bitbucket Server, Azure DevOps and Gogs. The following explains how to configure | ||
| a Git webhook for GitHub, but the same process should be applicable to other providers. | ||
|
|
||
| !!! note | ||
| The webhook handler does not differentiate between branch events and tag events where the branch and tag names are | ||
| the same. A hook event for a push to branch `x` will trigger a refresh for an app pointing at the same repo with | ||
| `targetRevision: refs/tags/x`. | ||
|
|
||
| ### 1. Create The WebHook In The Git Provider | ||
| ## 1. Create The WebHook In The Git Provider | ||
|
|
||
| In your Git provider, navigate to the settings page where webhooks can be configured. The payload | ||
| URL configured in the Git provider should use the `/api/webhook` endpoint of your Argo CD instance | ||
| (e.g. `https://argocd.example.com/api/webhook`). If you wish to use a shared secret, input an | ||
| arbitrary value in the secret. This value will be used when configuring the webhook in the next step. | ||
|
|
||
| ## Github | ||
|
|
||
|  | ||
|
|
||
| !!! note | ||
| When creating the webhook in GitHub, the "Content type" needs to be set to "application/json". The default value "application/x-www-form-urlencoded" is not supported by the library used to handle the hooks | ||
|
|
||
| ### 2. Configure Argo CD With The WebHook Secret (Optional) | ||
| ## Azure DevOps | ||
|
|
||
|  | ||
|
|
||
| Azure DevOps optionally supports securing the webhook using basic authentication. To use it, specify the username and password in the webhook configuration and configure the same username/password in `argocd-secret` Kubernetes secret in | ||
| `webhook.azuredevops.username` and `webhook.azuredevops.password` keys. | ||
|
|
||
| ## 2. Configure Argo CD With The WebHook Secret (Optional) | ||
|
|
||
| Configuring a webhook shared secret is optional, since Argo CD will still refresh applications | ||
| related to the Git repository, even with unauthenticated webhook events. This is safe to do since | ||
|
|
@@ -36,12 +45,14 @@ In the `argocd-secret` kubernetes secret, configure one of the following keys wi | |
| provider's webhook secret configured in step 1. | ||
|
|
||
| | Provider | K8s Secret Key | | ||
| |-----------------| ---------------------------------| | ||
| |-----------------|----------------------------------| | ||
| | GitHub | `webhook.github.secret` | | ||
| | GitLab | `webhook.gitlab.secret` | | ||
| | BitBucket | `webhook.bitbucket.uuid` | | ||
| | BitBucketServer | `webhook.bitbucketserver.secret` | | ||
| | Gogs | `webhook.gogs.secret` | | ||
| | Azure DevOps | `webhook.azuredevops.username` | | ||
| | | `webhook.azuredevops.password` | | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as a DevOps user I'd like a bit of clarity on what this password is - is it a PAT or something else? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This screenshot might be a good thing to add to docs. :-)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree :) created separate sections for Github and Azure DevOps and used this screenshot in Azure DevOps section. |
||
|
|
||
| Edit the Argo CD kubernetes secret: | ||
|
|
||
|
|
@@ -79,6 +90,10 @@ stringData: | |
|
|
||
| # gogs server webhook secret | ||
| webhook.gogs.secret: shhhh! it's a gogs server secret | ||
|
|
||
| # azuredevops username and password | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a note somewhere that azure devops uses only basic authentication and does not have secrets like others?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Added separate section for Azure DevOps with clarification about basic auth. |
||
| webhook.azuredevops.username: admin | ||
| webhook.azuredevops.password: secret-password | ||
| ``` | ||
|
|
||
| After saving, the changes should take effect automatically. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| { | ||
| "subscriptionId": "8fd412f1-9873-4b45-8854-655b1b8a2eff", | ||
| "notificationId": 2, | ||
| "id": "09b0b950-47fa-4f45-8b65-5a22686314f8", | ||
| "eventType": "git.push", | ||
| "publisherId": "tfs", | ||
| "message": { | ||
| "text": "Alexander Matyushentsev pushed updates to alex-test:master\r\n(https://dev.azure.com/alexander0053/alex-test/_git/alex-test/#version=GBmaster)", | ||
| "html": "Alexander Matyushentsev pushed updates to <a href=\"https://dev.azure.com/alexander0053/alex-test/_git/alex-test/\">alex-test</a>:<a href=\"https://dev.azure.com/alexander0053/alex-test/_git/alex-test/#version=GBmaster\">master</a>", | ||
| "markdown": "Alexander Matyushentsev pushed updates to [alex-test](https://dev.azure.com/alexander0053/alex-test/_git/alex-test/):[master](https://dev.azure.com/alexander0053/alex-test/_git/alex-test/#version=GBmaster)" | ||
| }, | ||
| "detailedMessage": { | ||
| "text": "Alexander Matyushentsev pushed a commit to alex-test:master\r\n - draft 298a79aa (https://dev.azure.com/alexander0053/alex-test/_git/alex-test/commit/298a79aa1552799a70718a0ee914d153d5a1a76b)", | ||
| "html": "Alexander Matyushentsev pushed a commit to <a href=\"https://dev.azure.com/alexander0053/alex-test/_git/alex-test/\">alex-test</a>:<a href=\"https://dev.azure.com/alexander0053/alex-test/_git/alex-test/#version=GBmaster\">master</a>\r\n<ul>\r\n<li>draft <a href=\"https://dev.azure.com/alexander0053/alex-test/_git/alex-test/commit/298a79aa1552799a70718a0ee914d153d5a1a76b\">298a79aa</a></li>\r\n</ul>", | ||
| "markdown": "Alexander Matyushentsev pushed a commit to [alex-test](https://dev.azure.com/alexander0053/alex-test/_git/alex-test/):[master](https://dev.azure.com/alexander0053/alex-test/_git/alex-test/#version=GBmaster)\r\n* draft [298a79aa](https://dev.azure.com/alexander0053/alex-test/_git/alex-test/commit/298a79aa1552799a70718a0ee914d153d5a1a76b)" | ||
| }, | ||
| "resource": { | ||
| "commits": [ | ||
| { | ||
| "commitId": "298a79aa1552799a70718a0ee914d153d5a1a76b", | ||
| "author": { | ||
| "name": "Alexander Matyushentsev", | ||
| "email": "AMatyushentsev@gmail.com", | ||
| "date": "2023-08-09T00:45:39Z" | ||
| }, | ||
| "committer": { | ||
| "name": "Alexander Matyushentsev", | ||
| "email": "AMatyushentsev@gmail.com", | ||
| "date": "2023-08-09T00:45:39Z" | ||
| }, | ||
| "comment": "draft\n\nSigned-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>", | ||
| "url": "https://dev.azure.com/alexander0053/_apis/git/repositories/ba2967cc-02c2-414c-8d10-1b99197cbaa6/commits/298a79aa1552799a70718a0ee914d153d5a1a76b" | ||
| } | ||
| ], | ||
| "refUpdates": [ | ||
| { | ||
| "name": "refs/heads/master", | ||
| "oldObjectId": "fa51eeb1e50b98293ce281e6d5492b9decae613b", | ||
| "newObjectId": "298a79aa1552799a70718a0ee914d153d5a1a76b" | ||
| } | ||
| ], | ||
| "repository": { | ||
| "id": "ba2967cc-02c2-414c-8d10-1b99197cbaa6", | ||
| "name": "alex-test", | ||
| "url": "https://dev.azure.com/alexander0053/_apis/git/repositories/ba2967cc-02c2-414c-8d10-1b99197cbaa6", | ||
| "project": { | ||
| "id": "ab1c194f-94fa-4d1a-87ff-e9458637d060", | ||
| "name": "alex-test", | ||
| "url": "https://dev.azure.com/alexander0053/_apis/projects/ab1c194f-94fa-4d1a-87ff-e9458637d060", | ||
| "state": "wellFormed", | ||
| "visibility": "unchanged", | ||
| "lastUpdateTime": "0001-01-01T00:00:00" | ||
| }, | ||
| "defaultBranch": "refs/heads/master", | ||
| "remoteUrl": "https://dev.azure.com/alexander0053/alex-test/_git/alex-test" | ||
| }, | ||
| "pushedBy": { | ||
| "displayName": "Alexander Matyushentsev", | ||
| "url": "https://spsprodcus4.vssps.visualstudio.com/A7a73fd0c-d080-434d-a8b4-0b4c0217e290/_apis/Identities/07220d5e-521c-683d-982c-726e80086d08", | ||
| "_links": { | ||
| "avatar": { | ||
| "href": "https://dev.azure.com/alexander0053/_apis/GraphProfile/MemberAvatars/aad.MDcyMjBkNWUtNTIxYy03ODNkLTk4MmMtNzI2ZTgwMDg2ZDA4" | ||
| } | ||
| }, | ||
| "id": "07220d5e-521c-683d-982c-726e80086d08", | ||
| "uniqueName": "alexander@akuity.onmicrosoft.com", | ||
| "imageUrl": "https://dev.azure.com/alexander0053/_api/_common/identityImage?id=07220d5e-521c-683d-982c-726e80086d08", | ||
| "descriptor": "aad.MDcyMjBkNWUtNTIxYy03ODNkLTk4MmMtNzI2ZTgwMDg2ZDA4" | ||
| }, | ||
| "pushId": 4, | ||
| "date": "2023-08-09T00:45:42.8315767Z", | ||
| "url": "https://dev.azure.com/alexander0053/_apis/git/repositories/ba2967cc-02c2-414c-8d10-1b99197cbaa6/pushes/4", | ||
| "_links": { | ||
| "self": { | ||
| "href": "https://dev.azure.com/alexander0053/_apis/git/repositories/ba2967cc-02c2-414c-8d10-1b99197cbaa6/pushes/4" | ||
| }, | ||
| "repository": { | ||
| "href": "https://dev.azure.com/alexander0053/ab1c194f-94fa-4d1a-87ff-e9458637d060/_apis/git/repositories/ba2967cc-02c2-414c-8d10-1b99197cbaa6" | ||
| }, | ||
| "commits": { | ||
| "href": "https://dev.azure.com/alexander0053/_apis/git/repositories/ba2967cc-02c2-414c-8d10-1b99197cbaa6/pushes/4/commits" | ||
| }, | ||
| "pusher": { | ||
| "href": "https://spsprodcus4.vssps.visualstudio.com/A7a73fd0c-d080-434d-a8b4-0b4c0217e290/_apis/Identities/07220d5e-521c-683d-982c-726e80086d08" | ||
| }, | ||
| "refs": { | ||
| "href": "https://dev.azure.com/alexander0053/ab1c194f-94fa-4d1a-87ff-e9458637d060/_apis/git/repositories/ba2967cc-02c2-414c-8d10-1b99197cbaa6/refs/heads/master" | ||
| } | ||
| } | ||
| }, | ||
| "resourceVersion": "1.0", | ||
| "resourceContainers": { | ||
| "collection": { | ||
| "id": "d54a3f95-82a0-47c4-8444-00da7391d976", | ||
| "baseUrl": "https://dev.azure.com/alexander0053/" | ||
| }, | ||
| "account": { | ||
| "id": "7a73fd0c-d080-434d-a8b4-0b4c0217e290", | ||
| "baseUrl": "https://dev.azure.com/alexander0053/" | ||
| }, | ||
| "project": { | ||
| "id": "ab1c194f-94fa-4d1a-87ff-e9458637d060", | ||
| "baseUrl": "https://dev.azure.com/alexander0053/" | ||
| } | ||
| }, | ||
| "createdDate": "2023-08-09T00:45:49.3448928Z" | ||
| } |

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.
Should we point to
gopkg.in/go-playground/webhooks.v6instead?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.
I tried but looks like there was a change and new package name is
github.com/go-playground/webhooks/v6. Here isgo getoutput: