argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
18.04k stars 5.51k forks source link

Feature Request: Add Azure Devops Pull Request generator Webhook #16716

Open GuitaristForEver opened 11 months ago

GuitaristForEver commented 11 months ago

when triggering a git webhook on pull request created argocd-server is ignoring the webhook, maybe it is not implemented for Azure Devops because on the documentation I can only see for GitHub and Gitlab:

image

https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/Generators-Pull-Request/#github-webhook-configuration

robinlieb commented 11 months ago

This is implemented and based on test should work, can you share some sample webhook payload and log messages related with that one? Nevertheless I could include that in docs once this is clarified.

GuitaristForEver commented 11 months ago

yes sure . Thanks @robinlieb .

sample webhook:

{
    "id": "13d59e73-9ba7-48f6-a372-1cf5f08e84ef",
    "eventType": "git.pullrequest.created",
    "publisherId": "tfs",
    "message": {
        "text": "test",
        "html": "test",
        "markdown": "test"    },
    "detailedMessage": {
        "text": "test",
        "html": "test",
        "markdown": "test"    },
    "resource": {
        "repository": {
            "id": "80cf150a-bcd9-4b3b-9169-0609db18eebd",
            "name": "services",
            "url": "https://myorg.visualstudio.com/f2ece68d-fd7e-4807-baf6-b989cd36d883/_apis/git/repositories/80cf150a-bcd9-4b3b-9169-0609db18eebd",
            "project": {
                "id": "f2ece68d-fd7e-4807-baf6-b989cd36d883",
                "name": "myProject",
                "description": "mu proj",
                "url": "https://myorg.visualstudio.com/_apis/projects/f2ece68d-fd7e-4807-baf6-b989cd36d883",
                "state": "wellFormed",
                "revision": 425836275,
                "visibility": "private",
                "lastUpdateTime": "2023-08-10T06:35:21.397Z"
            },
            "size": 2692280,
            "remoteUrl": "https://myorg.visualstudio.com/DefaultCollection/myProject/_git/services",
            "sshUrl": "myorg@vs-ssh.visualstudio.com:v3/myorg/myProject/services",
            "webUrl": "https://myorg.visualstudio.com/DefaultCollection/myProject/_git/services",
            "isDisabled": false,
            "isInMaintenance": false
        },
        "pullRequestId": 152078,
        "codeReviewId": 153071,
        "status": "active",
        "createdBy": {
            "displayName": "Yuval Gabay",
            "url": "https://spsprodeus21.vssps.visualstudio.com/A6ffa4227-7dbc-4bf2-96bf-05315c3e31a5/_apis/Identities/0aa2926d-6810-6194-b451-010640c81150",
            "_links": {
                "avatar": {
                    "href": "https://myorg.visualstudio.com/_apis/GraphProfile/MemberAvatars/aad.MGFhMjkyNmQtNjgxMC03MTk0LWI0NTEtMDEwNjQwYzgxMTUw"
                }
            },
            "id": "0aa2926d-6810-6194-b451-010640c81150",
            "uniqueName": "mymail@gmail.com",
            "imageUrl": "https://myorg.visualstudio.com/_api/_common/identityImage?id=0aa2926d-6810-6194-b451-010640c81150",
            "descriptor": "aad.MGFhMjkyNmQtNjgxMC03MTk0LWI0NTEtMDEwNjQwYzgxMTUw"
        },
        "creationDate": "2023-12-28T07:44:17.615548Z",
        "title": "Renamed uat-eus2 to pr-uat",
        "description": "Renamed uat-eus2 to pr-uat",
        "sourceRefName": "refs/heads/test_webhook",
        "targetRefName": "refs/heads/main",
        "mergeStatus": "succeeded",
        "isDraft": false,
        "mergeId": "2ddbea00-3b88-43e3-acfb-837cf1251365",
        "lastMergeSourceCommit": {
            "commitId": "7a593105cf20aef1cac8ac2b467b0fd03df7cc66",
            "url": "https://myorg.visualstudio.com/f2ece68d-fd7e-4807-baf6-b989cd36d883/_apis/git/repositories/80cf150a-bcd9-4b3b-9169-0609db18eebd/commits/7a593105cf20aef1cac8ac2b467b0fd03df7cc66"
        },
        "lastMergeTargetCommit": {
            "commitId": "22115bf2b7d510681f050ec19bdb08bdef9bf228",
            "url": "https://myorg.visualstudio.com/f2ece68d-fd7e-4807-baf6-b989cd36d883/_apis/git/repositories/80cf150a-bcd9-4b3b-9169-0609db18eebd/commits/22115bf2b7d510681f050ec19bdb08bdef9bf228"
        },
        "lastMergeCommit": {
            "commitId": "cd0c68236943679a544b099ef93e59324eebff2a",
            "author": {
                "name": "Yuval Gabay",
                "email": "mymail@gmail.com",
                "date": "2023-12-28T07:44:17Z"
            },
            "committer": {
                "name": "Yuval Gabay",
                "email": "mymail@gmail.com",
                "date": "2023-12-28T07:44:17Z"
            },
            "comment": "Merge pull request 152078 from test_webhook into main",
            "url": "https://myorg.visualstudio.com/f2ece68d-fd7e-4807-baf6-b989cd36d883/_apis/git/repositories/80cf150a-bcd9-4b3b-9169-0609db18eebd/commits/cd0c68236943679a544b099ef93e59324eebff2a"
        },
        "reviewers": [],
        "url": "https://myorg.visualstudio.com/f2ece68d-fd7e-4807-baf6-b989cd36d883/_apis/git/repositories/80cf150a-bcd9-4b3b-9169-0609db18eebd/pullRequests/152078",
        "_links": {
            "web": {
                "href": "https://myorg.visualstudio.com/myProject/_git/services/pullrequest/152078"
            },
            "statuses": {
                "href": "https://myorg.visualstudio.com/f2ece68d-fd7e-4807-baf6-b989cd36d883/_apis/git/repositories/80cf150a-bcd9-4b3b-9169-0609db18eebd/pullRequests/152078/statuses"
            }
        },
        "supportsIterations": true,
        "artifactId": "vstfs:///Git/PullRequestId/f2ece68d-fd7e-4807-baf6-b989cd36d883%2f80cf150a-bcd9-4b3b-9169-0609db18eebd%2f152078"
    },
    "resourceVersion": "1.0",
    "resourceContainers": {
        "collection": {
            "id": "3dee3d30-8f86-4210-96dd-8906a28f1929",
            "baseUrl": "https://myorg.visualstudio.com/"
        },
        "account": {
            "id": "6ffa4227-7dbc-4bf2-96bf-05315c3e31a5",
            "baseUrl": "https://myorg.visualstudio.com/"
        },
        "project": {
            "id": "f2ece68d-fd7e-4807-baf6-b989cd36d883",
            "baseUrl": "https://myorg.visualstudio.com/"
        }
    },
    "createdDate": "2023-12-28T07:44:24.741Z"
}

and the log i get from argocd-server pod is.

level=info msg="Ignoring webhook event"

pull request generator appset:

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: pull-request-services
  namespace: argocd
spec:
  generators:
    - matrix:
        generators:
        # Pull Request Generator 
        # https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/Generators-Pull-Request/
          - pullRequest:
              azuredevops:
                api: https://dev.azure.com
                labels:
                  - argopr
                organization: myorg
                project: myProject
                repo: services
                tokenRef:
                  key: token
                  secretName: azuredevops-token
          # Git Generator 
          # https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/Generators-Git/
          - git:
              files:
                - path: apps/services/**/pr-*/kustomization.yaml
              repoURL: >-
                https://myorg.visualstudio.com/MyProject/_git/services
              revision: '{{ branch }}'
  template:
    metadata:
      name: app-{{branch}}
    spec:
      destination:
        namespace: '{{branch}}'
        server: https://kubernetes.default.svc
      project: default
      source:
        path: '{{path}}'
        repoURL: https://myorg.visualstudio.com/myProject/_git/services
        targetRevision: '{{ branch }}'
      syncPolicy:
        automated:
          prune: true
          selfHeal: true
        syncOptions:
          - CreateNamespace=true
danijam commented 6 months ago

@GuitaristForEver We are about to start using Pull Request Generator & Azure DevOps and were searching to see if Webhooks were supported... Stumbled on this. Did you ever get Webhooks working for Azure DevOps & Pull Request Generator?

andrii-korotkov-verkada commented 2 weeks ago

What's your argocd version?