I have a gogs repository which is loaded from local directory (I will clone git repo to that local repository periodically). In repository settings there is an option called "Sync now" to sync the repository. How to invoke this Sync now option via a jenkins job. Is there any api for Syncing the repository. Thanks in advance.
Asked
Active
Viewed 78 times
1 Answers
0
I think Gogs provides an API for syncing. If you do have the personal access token from your Gogs account, you can trigger the repo sync.
curl -X POST \
-H "Authorization: token YOUR_PERSONAL_ACCESS_TOKEN" \
"http://YOUR_GOGS_URL/api/v1/repos/OWNER/REPO_NAME/sync"
Replace YOUR_PERSONAL_ACCESS_TOKEN
with the token you generated, 'YOUR_GOGS_URL
with the URL of your Gogs instance, OWNER
with the owner of the repository, and REPO_NAME
with the name of the repository.
Now all you have to do is schedule a Jenkins job to run in time intervals which will sync on regular basis.

Joypal
- 178
- 9
-
Getting page not found error Tried with mirror-sync api, it is working as expected, thank you . curl -X POST \ -H "Authorization: token YOUR_PERSONAL_ACCESS_TOKEN" \ "http://YOUR_GOGS_URL/api/v1/repos/OWNER/REPO_NAME/mirror-sync" – Velan Apr 17 '23 at 08:26