diff --git a/gitlab_docker_autodep/hooks.py b/gitlab_docker_autodep/hooks.py
new file mode 100644
index 0000000000000000000000000000000000000000..dc99626b786ef3e1dc7353514b05149dc13e2194
--- /dev/null
+++ b/gitlab_docker_autodep/hooks.py
@@ -0,0 +1,16 @@
+
+
+def check_hook(gl, hook_url, webhook_token, project_path):
+    project = gl.projects.get(project_path)
+    found = False
+    for h in project.hooks.list():
+        if h.url == hook_url and h.pipeline_events:
+            found = True
+            break
+    if found:
+        return
+    project.hooks.add(
+        url=hook_url,
+        pipeline_events=True,
+        token=webhook_token,
+    )
diff --git a/gitlab_docker_autodep/main.py b/gitlab_docker_autodep/main.py
index 58313d122f015ed23160d1d518f781d0ec124fa9..58f804f7c7180fc9bc95a44c106ddf0b3242f9d1 100644
--- a/gitlab_docker_autodep/main.py
+++ b/gitlab_docker_autodep/main.py
@@ -7,6 +7,7 @@ import urllib.parse as urlparse
 
 from .deps import get_branches, list_projects, list_deps, \
     split_project_branch, read_deps
+from .hooks import check_hook
 from .rebuild import rebuild_deps
 from .server import run_app
 
@@ -63,6 +64,20 @@ def main():
         '--docker', action='store_true',
         help='Output dependencies between Docker images, not Gitlab projects')
 
+    # Setup pipeline hooks on the specified projects.
+    set_hooks_parser = subparsers.add_parser(
+        'set-hooks',
+        parents=[common_parser],
+        help='set pipeline hooks on projects',
+        description='Set the pipeline hooks on the specified projects '
+        '(usually points at our own server)')
+    set_hooks_parser.add_argument(
+        '--hook-url', metavar='URL',
+        help='URL for the pipeline HTTP hook')
+    set_hooks_parser.add_argument(
+        '--webhook-auth-token', metavar='TOKEN',
+        help='Secret X-Gitlab-Token for request authentication')
+
     # Trigger rebuilds of reverse deps.
     rebuild_image_parser = subparsers.add_parser(
         'rebuild',
@@ -140,9 +155,17 @@ def main():
         project_path, branch_name = split_project_branch(args.project_path)
         rebuild_deps(gl, deps, project_path, branch_name, args.dry_run,
                      args.recurse)
+    elif cmd == 'set-hooks':
+        if not args.hook_url:
+            parser.error('Must specify --hook-url')
+        # Need a project list on input, ignore branches.
+        projects = set(y[0] for y in (
+            split_project_branch(x.strip()) for x in sys.stdin))
+        for project_path in projects:
+            check_hook(gl, args.hook_url, args.webhook_auth_token,
+                       project_path)
     elif cmd == 'server':
         deps = read_deps(sys.stdin)
-        # TODO
         run_app(gl, deps, args.bind_host, args.bind_port,
                 args.webhook_auth_token)