Triggering Redmine repository fetches from Git hooks

Redmine only reads new commits on its fetch schedule unless something asks it to. This page explains how to enable the repository management web service, call sys/fetch_changesets from a post-receive hook or CI job, and retire slow cron fetches.

On this page

How a push can trigger a Redmine repository fetch

Developers push to Git, but Redmine shows their changesets only after the next scheduled fetch. The supported way to close that gap is Redmine's repository management web service, sys/fetch_changesets, called with the repository management API key. Once something outside Redmine makes that call after a push, Redmine fetches the new commits for the repository and links them to issues without waiting for cron.

Redmine's repository configuration documentation describes this call. It fetches changesets for all active projects, or for a single project when you pass an id parameter, so a post-receive hook can target just the project whose repository changed. The web service must be enabled by an administrator under the repository settings before the call will succeed, and the repository management API key is a separate credential from an ordinary user's REST API key. Confirm both in your own Redmine version before you write the hook.

Be clear about the direction of traffic. This is a Redmine-side pull that an external system triggers, not a Redmine webhook. Redmine does not push events to your Git server, and the Git server does not write into Redmine's database. Your post-receive hook or CI job makes an authenticated HTTP request, and Redmine then reads the repository itself. That distinction matters for planning: the hook needs network access to Redmine, a stored key that is rotated and scoped like any other secret, and a retry or logging plan for failed calls, because a missed request leaves commits unlinked until the next scheduled fetch.

What you need before wiring the hook

The hook is only as reliable as the setup behind it. Four components have to be in place before you write a single line of hook code: the Redmine instance, the repository link, the administrator access that enables the web service, and a network path from your Git host or CI runner to Redmine.

A running Redmine on a supported line

Confirm that the Redmine instance you will call is on a version line that still receives updates. Redmine 7.0.x is the fully supported line and receives new features, bug fixes and security updates, while 6.1.x gets only bug fixes and security updates. Run the latest patch release on your chosen line before you add an automated caller, so you are not debugging a hook against an install that is about to change under you.

Redmine download page

A repository already linked in Redmine

The web service can only fetch changesets for repositories that Redmine already knows about. Check that the project has a repository of the right SCM type (Git in this case) configured with a path or URL the Redmine server can read. Run one manual fetch from the repository settings page first. If that fails, a hook will fail the same way, and the error will be harder to find in your Git server logs.

Administrator access to enable the web service

The repository management web service is switched on in the Redmine administration settings, and its API key is generated there as well. Someone with administrator rights must do both steps. Confirm who holds that role, and record that the key is a shared secret for the automation rather than a personal key, so it survives staff changes. The key grants fetch rights across repositories, so treat it as a credential from the start.

A Git host or CI runner that can call webhooks

A post-receive hook runs on the Git server itself, while a CI job runs on a runner. Confirm which one your team can control, and whether the Git server supports server-side hooks or your CI platform lets a job make an outbound HTTP request. Both options depend on the product and configuration in your own environment, so verify this with your platform administrators before you commit to a design.

HTTPS reachability from the caller to Redmine

The calling host must reach the Redmine URL over HTTPS, including through any firewall, proxy or network segment between them. Test the route from the exact machine or runner that will make the call, not from your workstation. Note any certificate authority that must be trusted by that host, because a request that fails on certificate validation will look like a network problem in the logs.

Configure the fetch call step by step

This sequence turns a slow scheduled repository refresh into a targeted call that Redmine answers as soon as a push lands, with each step confirmed before the next one starts. The result is one enabled web service, one credential, a tested manual fetch for a single project, and a hook or CI job that calls it for that project only.

  1. Enable the repository management web service

    A Redmine administrator opens Administration, then Settings, then the API tab, and turns on the repository management web service. This is the switch that allows the sys/fetch_changesets endpoint to respond at all, so it must be set before any other step can succeed. Confirm the change by saving the settings and reloading the page to check that the option stays enabled. If the endpoint later returns an authorization error, this setting is the first thing to re-check.

  2. Copy the repository management API key

    On the same API settings page, the administrator reads the repository management API key that Redmine displays for the instance. Store this key in your secrets manager or CI variable store as a service credential, not in a shared document or in the repository itself. Mark the entry with the purpose and the Redmine instance it belongs to so it can be rotated later. The check is that the key is retrievable from the store by the person or pipeline that will make the call.

  3. Confirm the target project identifier

    Before calling the endpoint, the Redmine administrator or project manager confirms the identifier of the one project that the push belongs to, as it appears in the project URL. Use this identifier in the id parameter so that a push to one repository refreshes only that project's changesets. Record the mapping between each Git repository and its Redmine identifier in your hook configuration. The check is a written mapping that a second engineer can review.

  4. Test sys/fetch_changesets manually against one project

    From a machine that can reach the Redmine server, send a request to sys/fetch_changesets with the repository management API key and the id parameter set to the project identifier from the previous step. Use an HTTPS request to your own Redmine URL and avoid placing the key in shared shell history. A successful response from the server indicates that Redmine accepted the key and found the project's repository. If the response is an error, check the web service setting, the key value and the project identifier before continuing.

  5. Verify the changeset in the Redmine repository view

    Open the Repository tab of the test project in the Redmine web interface and look for the most recent commits from the Git remote. Compare the newest commit hash and message with the output of git log on the server that holds the bare repository. Seeing the same latest commit confirms that the fetch worked for that project. If the commit is missing, look at the repository settings for the correct path and confirm that the Git user Redmine runs as can read the repository.

  6. Add the call to a post-receive hook or CI job

    Add a post-receive hook on the Git server, or a final job in the CI pipeline that runs on the main branch, to send the same request with the project identifier for that repository. Store the key in the hook environment or CI secret variable rather than in the script text, and set a short timeout so a slow Redmine response does not block the push. Keep the hook limited to the branches Redmine tracks. The check is that the hook exits with a success status when run manually.

  7. Push a test commit and confirm the new changeset

    Make a small commit on a tracked branch, push it, and wait for the hook or CI job to finish. Open the Redmine repository view for the same project and confirm that the new commit appears without a scheduled fetch running. Also check that a push to a second, unrelated repository does not change the first project's changesets, which shows the call is restricted correctly. If the commit does not appear, review the hook output and the Redmine production log for the request.

What sys/fetch_changesets does and does not do

The sys/fetch_changesets call asks Redmine to read new commits from its configured repositories and store them as changesets. It can run for every active project or for a single project when the id parameter is passed. In practical terms, the call performs the same work as the scheduled fetch that many Redmine installations already run, but it starts on demand. A post-receive hook or CI job can therefore trigger the fetch right after a push instead of waiting for the next cron run. The call does not add new behavior to how Redmine reads repositories, so commit visibility, issue references and repository permissions work as they do after a scheduled fetch.

The cost of each call depends on the size of what Redmine has to read. A large repository with a long history, or a single call covering many active projects, makes the fetch heavier, and that load lands on the same application server and database that serve users. Concurrent pushes add a second risk: two hooks can request fetches for the same repository at nearly the same time, so the runs can overlap. Plan for this by serializing calls per project in the hook or CI job, and by scoping calls with id where a single project is enough. Confirm how your Redmine version handles overlapping fetches and what response the call returns before you rely on it.

The call does not replace a scheduled fallback. If a hook fails, a CI runner is offline or a network path changes, commits will not appear until someone notices, so keep the cron fetch running during the transition and afterwards at a lower frequency. Confirm with your own Redmine version and Redmine repositories documentation whether the web service imposes any rate limits, how long a call may take, and what the response contains on success and failure, and record those answers in your runbook.

Mapping pushes, projects and repositories to fetch calls

This table maps each part of a push-to-fetch flow, from the Git event to the Redmine project, repository and credential, and shows the choice between one call per project and one call for all projects. Read each row as a setting to decide on before writing the hook script, because a mismatch in any one of them leaves commits missing from Redmine without an obvious error.

ElementWhat to setWhy it matters
Git eventPost-receive hook on the Git host, or a final CI job step after a successful pushA post-receive hook fires on every push, including force pushes and tag pushes, so the script should filter branches it does not need to fetch.
Redmine project identifierThe project identifier passed as the id parameter, matching the identifier shown in Redmine's project settingsA hook that sends the wrong identifier fetches nothing for the intended project, and the mismatch can go unnoticed.
Repository in RedmineThe repository configured under the project's Repositories settings, using the same path or URL the hook is tied toRedmine fetches only repositories it knows about, so a project with no configured repository has nothing to update.
CredentialThe repository management API key stored in a secret manager or CI variable, not a named user's personal API keyA personal key stops working when the user leaves or changes role, and it ties fetch activity to one person in audit logs.
One call per projectA request with the id parameter for each project whose repository changedFetch work stays limited to the affected repository, which suits instances with many projects or large repositories.
One call for all active projectsA request without an id parameter that fetches changesets for all active projectsSimpler hook logic with one endpoint, but every push triggers work across the instance, so it fits smaller installations better.
Naming conventionHook script or CI job name derived from the Redmine project identifier, for example a repository variable set to that identifierKeeps scripts aligned with Redmine identifiers when repositories are renamed or copied, and makes the mapping reviewable in one file.
Repository management serviceThe repository management web service enabled in Redmine's settings before any call is madeWithout it the endpoint does not respond to the fetch call, so confirm this setting in each environment first.

Securing the repository management API key

The repository management API key lets any caller trigger changeset fetches across Redmine, so it needs the same care as a deployment credential. The cards below cover where the key lives, who can read the hook scripts that use it, how Redmine is reached, how far the key reaches, and how it is rotated. Confirm the exact storage, access and permission options in your own Git platform and CI system before you apply them.

Store the key as a secret

Keep the repository management API key in the Git server's or CI system's secret store, never in the repository, a hook script committed to version control, or a shared wiki page. Reference it by variable name from the hook or job so the value is not written into logs or job output. Check that the platform masks the value in logs and that forked or pull-request pipelines cannot read it. Confirm these behaviors in your own Git platform, since the option names differ between products.

Restrict who can read hook scripts

A post-receive hook or CI job that calls sys/fetch_changesets exposes the endpoint and the variable that holds the key to anyone who can edit or view it. Limit edit rights on server-side hooks to the platform team, and review who can change CI pipeline definitions on the branches that run the fetch. Treat any change to these files as a change to a credential path and record it in your change process.

Serve Redmine only over HTTPS

Call the fetch endpoint only at an HTTPS address for your Redmine instance, so the key is not sent in clear text on the network between the Git server, the CI runner and Redmine. Confirm the certificate chain is trusted by the hosts that make the call, and that the URL in the hook does not fall back to plain HTTP through a redirect. Where the Git server and Redmine sit on different networks, confirm the path between them is the one you intend to expose.

Scope the call to the minimum projects

The web service can fetch changesets for all active projects or for one project through the id parameter. Where a hook only updates one repository, pass that project identifier so a leaked or misused call cannot trigger work across every project. Confirm in your Redmine version how the id parameter behaves when it is omitted, and document which hooks use the all-projects form.

Redmine repository docs

Rotate the key on staff and host changes

Replace the repository management API key when a person who knew it leaves, when a CI runner or Git server is retired, or when a hook script is copied to a new host. Update every stored copy at the same time, then confirm the next push still triggers a fetch. Record the rotation date in your operations log so the key's age is known during reviews.

Review the web service setting

The repository management web service is enabled by an administrator in Redmine's settings. Leave it off on instances that do not use hook-triggered fetches, and review the setting whenever the fetch design changes or the instance is upgraded. Ask whoever administers Redmine to confirm which account owns the key and that the setting matches the approved design.

How a push reaches the Redmine repository view

The flow starts when a developer pushes to the Git server, which runs a post-receive hook or a CI job. That hook calls the sys/fetch_changesets web service over HTTPS, sending the repository management API key. Redmine then fetches the new changesets from the repository and stores them, so they appear in the repository view. Check the boundary where the key leaves the Git host or runner, and confirm that the key is held in a secret store rather than in the hook script itself.

A push triggers a fetch call that makes new commits visible in Redmine.

Questions teams ask before connecting Git pushes to Redmine

Can our team set up Git-push fetches in Redmine without outside help?

Yes, in most setups it is a short administrative change plus a hook script, so an internal team with Redmine and Git administration skills can usually do it. The effort depends on how many repositories you have, which Git platform hosts them, and whether your CI system already runs jobs after pushes. Teams that lack an administrator with access to both Redmine and the Git host, or that need a security review of the API key and network path, often bring in outside help for the review and the rollout.

What makes the effort for this change grow or shrink?

The main drivers are the number of repositories, the Git hosting platform, the CI setup, and the security review. Each repository needs its own hook or job that calls the fetch endpoint, so a few repositories are simple while dozens need a shared template. Gitea, Forgejo and GitLab each expose hook or CI options in different places, which changes the work. A security review of the repository management API key and the network path from the Git host to Redmine can add time, so ask for it to be scoped in writing before work starts.

Should we keep the cron fetch after adding a push hook?

Yes, keep a scheduled fetch as a fallback during rollout. A hook can fail when the network is interrupted, when the Redmine host is restarting, or when a repository is added without a hook. The sys/fetch_changesets call from cron catches changesets that the hook missed. Once the hook has run reliably for a period your team agrees on, you can lengthen the cron interval or remove it, but this decision should be made from your own logs rather than from a fixed rule.

What does the team need to provide for this work?

You need three roles. An administrator in Redmine enables the repository management web service, creates or assigns the API key, and confirms which projects the fetch covers. A Git platform owner adds the hook or CI job and controls which network paths the call can use. A test project lets you push a commit, confirm it appears in Redmine, and check that the fetch runs without error before you apply the change to production projects.

How is this different from Redmine webhooks?

The two features point in opposite directions. This approach has your Git platform call Redmine so that Redmine reads new commits from the repository. Redmine webhooks, introduced in Redmine 7.0, push Redmine events such as issue, wiki and time entry changes outward to chat, CI or automation tools. You may use both, for example a push hook that updates changesets and a webhook that notifies a chat channel when an issue changes, but they solve different problems and need separate security reviews.

Does this work with Gitea, Forgejo or GitLab?

The fetch call is an ordinary HTTP request, so any Git platform that can run a script or job after a push can trigger it. The exact mechanism differs: Gitea, Forgejo and GitLab each offer hook or CI options with their own configuration and their own limits. Confirm the hook or CI options for your platform and version in that platform's documentation before you commit to a design, and test the call from the Git host's network to your Redmine instance.

What security checks apply to the repository management API key?

The repository management web service uses an API key that can trigger fetches for all active projects or one project, so treat it as a credential with broad effect. Store it in your secrets system rather than in a repository, limit the network paths that can reach the endpoint, and rotate it when people or systems change. Review who can read the hook configuration, because anyone who sees the key can call the endpoint. Your security team should record the decision and the rotation method.

Why fetches fail silently and how to diagnose them

A failed fetch call rarely produces a visible error in the hook or CI job that made it, and Redmine itself does not show a banner when a changeset did not arrive. The most common cause is the repository management web service being disabled, which an administrator turns on in the Redmine settings. Next check the API key: the call must use the repository management key from the user's account, and a key that was regenerated or rotated stops working without any warning in the hook log. Test the call by hand with curl against sys/fetch_changesets, once for all projects and once with the id parameter for one project. A response that is not a success points to the service or the key. If the response is a success but the commits are still missing, the commits are probably not there yet or the project is not the one you think it is.

A project identifier mismatch is the next suspect. The id parameter takes the Redmine project identifier, which is often different from the display name and from the Git repository name, so a copied name silently fetches nothing for the intended project. Confirm the identifier in the project settings and compare it with the URL of the project in Redmine. The timing problem is easy to miss: a post-receive hook or CI step that calls the endpoint before the push has finished updating the repository can return before the new commits exist. Check the order of events by running git log on the Redmine server's copy of the repository after a push, and add a short retry or call the endpoint from a step that runs after the push is complete. Large repositories cause the opposite symptom, a slow response that times out in the hook or runner. Compare the duration of a manual call against a small repository, and consider scoping the call to one project instead of all active projects.

The last failure point is network reachability. A CI runner in a separate network segment, behind a proxy, or without the Redmine hostname in its DNS may be unable to reach the Redmine URL at all, and the job may report success because the call was wrapped in a command that ignores errors. Run the same curl command from the runner itself, not from your workstation, and make the job fail on a non-success HTTP status. Once a call succeeds, open the repository view in Redmine and confirm that the latest commit appears with its timestamp. If it does not, return to the earlier checks before assuming a Redmine bug.

Diagnosing failed repository fetches

This table maps each common symptom of a failed sys/fetch_changesets call to its likely cause and the specific fix on the fetch call or the Redmine side. Read it by matching what you see in the hook or CI log, then checking the listed cause before changing anything. Most failures come from the API key, the enabled setting, or the project identifier used in the request.

SymptomLikely causeFix
Authentication rejectedThe key sent is not the repository management API key, or the key was regenerated and the hook still holds the old valueCopy the current key from the administrator's account page, store it as a CI secret or server environment variable, and send it in the request as the key parameter
Service not found or disabledThe repository management web service is not enabled in Redmine administration settings, so sys/fetch_changesets does not respond as expectedEnable the repository management web service in administration settings, then confirm the endpoint responds with a test call before wiring the hook
No new changesets after a pushThe hook runs before the push is complete, targets the wrong Redmine URL, or calls the fetch without an id for a project that is not activeConfirm the hook runs after the ref update, check the base URL and path, and pass the project id to target one project directly
Changesets appear in the wrong projectThe id parameter holds another project's identifier, or the hook is shared across repositories without a per-repository mappingGive each repository its own hook or CI job with the matching Redmine project identifier, and verify with one commit before adding more
Timeouts on large repositoriesThe fetch processes full history on a large repository, or the web server or proxy closes the request before the fetch completesRun the call asynchronously from the hook or CI job, raise the proxy timeout for that path only, and review the repository wiki on fetch behavior for large codebases
Duplicate or overlapping fetchesSeveral hooks, CI jobs and scheduled cron fetches call the same endpoint at once, or a push triggers multiple webhooksKeep one trigger per repository, remove redundant cron entries once hooks work, and serialize calls per project in the CI pipeline

Replacing slow cron fetches safely

A phased cutover moves repository fetching from scheduled cron runs to a post-push hook without losing commits. Each phase ends with a check that the hook is reliable before the schedule is reduced.

  1. Confirm the web service and API key

    An administrator enables the repository management web service in Redmine and the team confirms the repository management API key belongs to a service account with the right repository access. The owner records where the key is stored, outside the hook script. The step is done when a manual call to sys/fetch_changesets for one test project returns without an authentication error and the new commits appear in that project's repository view.

  2. Install the hook beside the existing cron job

    The platform team adds a post-receive hook or CI job that calls sys/fetch_changesets for the single project tied to the repository, passing the project identifier as the id parameter. The existing cron fetch keeps running unchanged, so both paths run in parallel. The step is done when a test push to a non-production branch triggers the hook and the hook log shows a successful HTTP response from Redmine.

  3. Log every hook and cron run

    Before the comparison starts, the team records the time of each hook call, its HTTP status and the cron run times, either in the hook script's log or in the CI job output. Logs are kept in a location the operations team can search. The step is done when a sample push produces one hook log entry and the cron log entry for the same window can be found and matched.

  4. Compare commit visibility across several pushes

    For several pushes spread over normal working days, the team checks that each new commit appears in Redmine's changesets for the repository, and notes which path made it visible first. Mismatches, such as a commit that never showed up or appeared only after the next cron run, are investigated before continuing. The step is done when the team has a written record of every push and no commit was missing from Redmine after the hook ran.

  5. Test failure and retry behavior

    The team deliberately makes Redmine unreachable or uses a wrong key in a test environment, then checks that the hook logs the failure and that the cron fetch still brings the commits in. This shows how the platform behaves when a hook run is missed. The step is done when the failure is logged clearly, alerting or a review point is defined, and the cron job is confirmed to recover the missed commits.

  6. Reduce cron frequency without removing it

    Once the comparison is clean, the operations team lengthens the cron interval for the fetch job, keeping it as a fallback for missed hook runs rather than deleting it. The new schedule is written into the runbook with an owner. The step is done when the changed schedule is live and the next pushes still appear in Redmine on time through the hook.

  7. Document the fallback schedule and ownership

    The runbook records which path is primary, which is the fallback, who checks the hook logs, and what to do when a commit is missing. Access to the API key and the hook configuration is limited to named maintainers. The step is done when the runbook has been reviewed by the team that will operate it and a missing-commit procedure has been walked through once.

What DeployOpen handles and what your team keeps

DeployOpen plans and implements the fetch connection inside your infrastructure. That covers enabling the repository management web service in Redmine, creating and scoping the repository management API key, writing the post-receive hook or CI job that calls sys/fetch_changesets, storing the key in your secret store rather than in repository files, and testing that a push produces the expected changesets in the right project. Each piece is documented so your administrators can review it and change it later. The work is delivered under a written scope, so the list of Git hosts, Redmine projects and job types covered is agreed before any configuration starts.

Your team keeps the decisions that depend on your own governance. Repository permissions in Git, administration of the Git platform itself, and the policy on who may trigger fetches or rotate the API key remain with your engineering and security staff. Confirm who approves changes to the Redmine service account, where the key will be held and who can read it, and whether the CI runner or hook host is allowed to reach Redmine over the network. Ask your Git platform administrators which events they will allow to call Redmine, since a broad hook on every repository affects every project in Redmine.

Plan for the operational work after handover. Someone on your side must own key rotation, review of the Redmine logs when a fetch fails, and updates to the hook when repository URLs or Redmine hostnames change. Ask any implementation partner, DeployOpen included, to state in the quote which of these tasks are one-time and which are recurring, and whether retesting after a Redmine upgrade is part of the fixed scope or a separate retainer.

How DeployOpen works on this

DeployOpen plans and implements self-hosted Redmine inside your own infrastructure, including the repository fetch trigger, the repository management web service and the hook or CI job that calls it. The work starts with a written scope that names the repositories, projects and fetch paths involved, so the result can be checked against it.

How we scope

  • Inventory which repositories, Redmine projects and hosting platforms need near-immediate changeset fetches and which can stay on schedule.
  • Confirm the Redmine version, the repository management web service setting and where the API key will be stored.
  • Agree in writing whether the scope covers one project, all active projects, or the hook and CI jobs across several Git hosts.

How we build

  • Enable the repository management web service, create the dedicated key for it, and restrict its use to the fetch call only.
  • Write the post-receive hook or CI job that calls sys/fetch_changesets, with the project id parameter where one project is targeted.
  • Test pushes, failed calls and repeated fetches in a staging copy, then confirm commits appear under the correct repository view.

How we hand over

  • Deliver the hook or CI configuration, the secret locations and a runbook explaining how to rotate the key and retire old cron jobs.
  • Document the fetch behavior, including what happens when Redmine is unreachable during a push and how to re-run a fetch manually.
  • Walk your operations team through verification steps so they can confirm a new commit appears in Redmine after each change.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
  • Ongoing support, Redmine upgrades and continuous testing are available as a retainer, which covers the fetch integration after upgrades.
  • Ask for a quote based on the written scope, since DeployOpen does not publish a price list.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.