Fetching Git Sync Activity via API

,

Hello Everybody.

Introduction

In the Harness Config As Code page we have a Git sync Activity Tab which lists the details of the Repo and the Status of the commits coming from the Git end. In order to check each commit it is required for the user to go into each commit into the UI and check the files.

This becomes tedious when you are dealing with multiple commits paralelly which have a huge volume of changed files which need some verification and validation, to do this having an API which returns these details would help.

Summary

Harness provides the below API which can be called using the Account ID and the Bearer Token and this lists the commit and the changed files details like in the UI as JSON output.

curl 'https://app.harness.io/gateway/api/git-sync/commits?accountId=<Acc_ID>&appId=__GLOBAL_APP_ID__&offset=0&limit=100' \
  -H 'authority: app.harness.io' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'authorization: Bearer <Bearer Token>' \
  --compressed

You can format this better by using JQ as well so the output looks like below

curl 'https://app.harness.io/gateway/api/git-sync/commits?accountId=<Acc_ID>&appId=__GLOBAL_APP_ID__&offset=0&limit=100' \
  -H 'authority: app.harness.io' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'authorization: Bearer <Bearer Token>' \
  --compressed | jq

1 Like