Hi,
I am using 1.14.1 and we would like to automate our onboarding process as much as possible. Gitea access is granted through the use of Active Directory groups. We would like to script that process so we can do the following steps:
- add user to AD group (already done)
- trigger Gitea external sync (this is our current gap since we have to do this part manually).
- call Gitea’s API every minute until it finds the new user (already done).
- send email to onboarded users (already done)
I can’t seem to find any endpoint for this in the API. However, I would like to know what command the sync task is doing so I can call it myself as part of my script.
Thanks for help.
I also haven’t found a way to do this from the API calls offered. And granted, I’m using a much newer version (1.21.11). However, I have found a way to do it by setting up a cron job setup in Gitea’s app.ini. It looks like this…
[cron.sync_external_users]
ENABLED = true
SCHEDULE = @every 5m
UPDATE_EXISTING = true
From this, the name of the job will be sync_external_user
. To verify that, run the following command to pull the information about the job (replacing connect_url
and api_token
with values appropriate to you…
curl -s -X GET "${connect_url}/admin/cron" -H "Authorization: token ${api_token}" -H "accept: application/json" -H "Content-Type: application/json" | jq '.[] | select(.name == "sync_external_users")'
Now to run this task, run the following command…
curl -s -X POST "${connect_url}/admin/cron/sync_external_users" -H "Authorization: token ${api_token}" -H "accept: application/json" -H "Content-Type: application/json"
If you run the GET api command above, you will notice that the exec_times
value should have increased. And, of course, your users should be added to their respective teams should the Gitea team to AD group map is correct.