Top Menu

Jump to content
Home
    Modules
      • Projects
      • Activity
      • Work packages
      • Gantt charts
      • Calendars
      • Team planners
      • Boards
      • News
    • Getting started
    • Introduction video
      Welcome to OpenProject Community
      Get a quick overview of project management and team collaboration with OpenProject. You can restart this video from the help menu.

    • Help and support
    • Upgrade to Enterprise edition
    • User guides
    • Videos
    • Shortcuts
    • Community forum
    • Enterprise support

    • Additional resources
    • Data privacy and security policy
    • Digital accessibility (DE)
    • OpenProject website
    • Security alerts / Newsletter
    • OpenProject blog
    • Release notes
    • Report a bug
    • Development roadmap
    • Add and edit translations
    • API documentation
  • Sign in
      Forgot your password?

      or sign in with your existing account

      Google

Side Menu

  • Overview
  • Activity
    Activity
  • Roadmap
  • Work packages
    Work packages
  • Gantt charts
    Gantt charts
  • Calendars
    Calendars
  • Team planners
    Team planners
  • Boards
    Boards
  • News
  • Forums

Content

Support Installation & Updates
  1. OpenProject
  2. Forums
  3. Support Installation & Updates
  4. Refresh repository changes

Refresh repository changes

Added by David Holland about 6 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 (7)

RE: Refresh repository changes - Added by Oliver Günther about 6 years ago

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

RE: Refresh repository changes - Added by David Holland about 6 years ago

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...

RE: Refresh repository changes - Added by David Holland about 6 years ago

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`!

RE: Refresh repository changes - Added by David Holland about 6 years ago

Also is there some documentation on this somewhere?

At the moment this is very "magical" if you know what I mean

RE: Refresh repository changes - Added by Nico Aymet over 4 years ago

I solved with a cron on following command:

curl -k "https://localhost/sys/fetch_changesets?id=PROJECT_IDENTIFIER&key=API_KEY"

RE: RE: Refresh repository changes - Added by Joris Ceelen 9 months ago

Yes I was hoping there would be some kind of hook that would automatically do this after I push to the git repo. The commit message is quite important in our workflow as it will show us exactly what has been done and when on the issue, the parsing of issue mentions in the git commit messages are a very important.

Now I still have to visit the repo page to make it refresh.

Is there a hook on the git http backend we can tie in to? We also have many projects so setting up a job for each project is cumbersome...

For now I created a workaround thanks to your tip:

If you create a file in /home/openproject/scripts called fetch_git_changeset.rb as shown below you can run it with

openproject run bundle exec rails runner /home/openproject/scripts/fetch_git_changesets.rb 

But I would love to make it a bit smarter so it would skip repos that have not changed, any tips welcome ?

# Fetch changesets for all projects
Project.all.each do |project|
  if project.repository
    begin
      puts "Fetching changesets for project #{project.identifier}"
      project.repository.fetch_changesets
    rescue => e
      puts "Failed to fetch changesets for project #{project.identifier}: #{e.message}"
    end
  else
    puts "No repository found for project #{project.identifier}"
  end
end

RE: Refresh repository changes - Added by Nico Aymet 6 months ago

Nico Aymet wrote:

I solved with a cron on following command:

curl -k "https://localhost/sys/fetch_changesets?id=PROJECT_IDENTIFIER&key=API_KEY"

Using curl not working anymore, the /sys/fetch_changesets route has been removed in app/controllers/sys_controller.rb

  • (1 - 7/7)
Loading...