Content
Refresh repository changes
Added by David Holland about 5 years ago
I am using gitea for my git repositories. In my openproject project, I use a local path for the repository.
The only problem I have, is that if I reference a work package through my commit message, I have to explicitly go to the Reporitory section and also select the correct branch for the reference to update!
My question is, if there is any API method, or link I can setup as a post-push hook for openproject to update automatically, because it is really annyoing to constantly navigate to the repository view, in order for commit references to be processed!
Replies (5)
Hi David,
There is the repository web services you can enable in the system settings of OpenProject.
Then you can request GET /sys/fetch_changeset?id=project-identifier
This can also be done a from job. Please note the sys API is only available from localhost on packaged installations.
Alternatively you can also setup a Cron job to run a command:
openproject run bundle exec rails runner "Project.find('identifier').repository.fetch_changesets"
Best,
Oliver
Okay, I thought about doing the cronjob approach, as I saw that directly below the checkbox to enable the webservice, an api key is provided, but gitea only lets me specify an url, a content type and a secret, but to my understanding, you need to authorize with username: apikey and the api key as a password.
The question is, whether I could also run a cronjob for all my projects, or do I have to add every project manually?
Or am I completely mistaken and you don't need any authorization for the update and/or do some magic with the webhook secret? Sorry that I'm kinda lost here...
If I try to issue the GET request you have specified from the same machine (`http://localhost:6000/sys/fetch_changeset?id=project-identifier`), I unfortunately get the error `404: not found`!
Also is there some documentation on this somewhere?
At the moment this is very "magical" if you know what I mean
I solved with a cron on following command:
curl -k "https://localhost/sys/fetch_changesets?id=PROJECT_IDENTIFIER&key=API_KEY"