gitdeploymentcrongithookscrontrigger

Auto-run script when remote git repository changes?


How do I automatically run a script whenever a specified remote git repository (on bitbucket) changes?

The script will contain lines to git pull dependant repositories; run tests; and if tests pass, deploy then reload relevant services.


Solution

  • The best solution is to use a Bitbucket hook to get notified when something changes in the remote repository and probably the easiest way to implement this is to have a CI software to listen for the notification and run your bar script.

    The complicated way is to write code yourself to receive the notification; I found an example that you might use as a starting point (and another one, even more complete)

    And, of course, you could always periodically poll for remote changes, but that's not very efficient. Best way is to use the hooks.