Configurer manuellement les webhooks dans Argo CD

  • Rversion finale: Zurich
  • Mis à jour 31 juil. 2025
  • 1 minute de lecture
  • Configurez les webhooks dans Argo CD pour envoyer des notifications de synchronisation à l’application Vélocité de changement DevOps.

    Avant de commencer

    Rôle requis : administrateur Argo CD

    Pourquoi et quand exécuter cette tâche

    Les événements de l’abonnement à l’application Argo CD peuvent être définis à l’aide de l’annotation notifications.argoproj.io/subscribe.<trigger>.<service> : <destinataire> .

    Procédure

    1. Dans Argo CD, mettez à jour la ConfigMap : argocd-notifications-cm.yaml pour configurer les notifications envoyées à Vélocité de changement DevOps.
      apiVersion: v1 
      kind: configMap 
      metadata: 
        name: argocd-notifications-cm 
        namespace: default 
      data: 
        context: | 
          argocdUrl: "https://<argocdURL>" 
        service.webhook.sn_devops_argocd: | 
          url: https://<instance>.service-now.com/api/sn_devops/v2/devops/tool/orchestration?toolId=<toolId> 
          basicAuth: #optional username password 
            username: "" 
            password: "" 
        template.app-sync-succeeded: | 
          webhook: 
            sn_devops_argocd: 
              method: POST 
              body: | 
                {  
                "titleLink" : "http://<argocdURL>/applications/{{.app.metadata.name}}", 
                "syncStatus" : "{{.app.status.sync.status}}", 
                "repo" : "{{.app.spec.source.repoURL}}", 
                "revision": "{{.app.status.sync.revision}}", 
                "path": "/repos/{{call .repo.FullNameByRepoURL .app.spec.source.repoURL}}/statuses/{{.app.status.operationState.operation.sync.revision}}", 
                "commitAuthor" : "{{(call .repo.GetCommitMetadata .app.status.sync.revision).Author}}", 
                "commitMessage" : "{{(call .repo.GetCommitMetadata .app.status.sync.revision).Message}}", 
                "commitTags" : "{{(call .repo.GetCommitMetadata .app.status.sync.revision).Tags}}", 
                "startedAt" : "{{.app.status.operationState.startedAt}}", 
                "finishedAt" : "{{.app.status.operationState.finishedAt}}", 
                "message": "{{.app.metadata.name}} app is synced" 
                } 
        trigger.on-sync-status-unknown: | 
          - description: Application status is 'Unknown' 
            send: 
            - app-sync-status-unknown 
            when: app.status.sync.status == 'Unknown' 
        trigger.on-sync-succeeded: | 
          - description: Application syncing has succeeded 
            send: 
            - app-sync-succeeded 
            when: app.status.operationState.phase in ['Succeeded'] 
        subscriptions: | 
          - recipients: 
            - sn_devops_argocd 
            triggers: 
            - on-sync-succeeded 
            - on-sync-status-unknown
    2. Ouvrez l’application Argo CD pour laquelle vous configurez des webhooks.
    3. Accédez à DÉTAILS DE L’APPLICATION > RÉSUMÉ.
    4. Ajoutez l’annotation notifications.argoproj.io/subscribe.<trigger>.<service> : <destinataire> avec la condition de déclenchement pour synchroniser l’état du changement de votre instance.
      Par exemple, notifications.argoproj.io/subscribe.on-sync-succeeded.sn_devops_argocd.Abonnement aux notifications.