Commit c20d5b6c authored by mh's avatar mh
Browse files

add patch to fix webhook creation + add cronjob script

parent 4555b35a
Pipeline #5228 failed with stage
in 27 seconds
From c775df13bacee8fa0ac135f1c126a796afe643b9 Mon Sep 17 00:00:00 2001
From: ng <ng@immerda.ch>
Date: Wed, 30 Dec 2020 13:48:57 +0100
Subject: [PATCH] fix creation of project hooks
---
gitlab_deps/hooks.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/gitlab_deps/hooks.py b/gitlab_deps/hooks.py
index abaf399..b97b3d4 100644
--- a/gitlab_deps/hooks.py
+++ b/gitlab_deps/hooks.py
@@ -12,8 +12,9 @@ def check_hook(gl, hook_url, webhook_token, project_path, dry_run):
return
logging.info('adding pipeline_events hook to %s', project_path)
if not dry_run:
- project.hooks.create(
- url=hook_url,
- pipeline_events=True,
- token=webhook_token,
- )
+ project.hooks.create({
+ 'url': hook_url,
+ 'push_events': False,
+ 'pipeline_events': True,
+ 'token': webhook_token,
+ })
--
2.29.2
......@@ -8,16 +8,18 @@ LABEL name="$NAME" \
summary="Provides a gitlab CI build orchestration toolkit." \
maintainer="immerda admin team <admin@immerda.ch>"
COPY gitlab-deps /tmp/gitlab-deps
COPY gitlab-deps gitlab-deps-cron *.patch /tmp/
RUN dnf install -y python3-cheroot python3-flask diffutils && \
cd /tmp/gitlab-deps && python3 setup.py install && \
cd /tmp/gitlab-deps && git am < ../*.patch && \
python3 setup.py install && \
mkdir /var/lib/gitlab-deps && chown -R user:user /var/lib/gitlab-deps && \
chmod +x /tmp/gitlab-deps/contrib/* && \
chmod +x /tmp/gitlab-deps/contrib/* /tmp/gitlab-deps-cron && \
sed -i 's@usr/sbin@usr/local/sbin@' /tmp/gitlab-deps/contrib/* && \
sed -i 's@usr/bin@usr/local/bin@' /tmp/gitlab-deps/contrib/* && \
sed -i 's/^reload=.*/reload=0/' /tmp/gitlab-deps/contrib/update.sh && \
cp -a /tmp/gitlab-deps/contrib/start-server.sh /usr/local/sbin/gitlab-deps-server-wrapper && \
cp -a /tmp/gitlab-deps/contrib/update.sh /usr/local/sbin/update-gitlab-deps && \
cp -a /tmp/gitlab-deps-cron /usr/local/bin/gitlab-deps-cron && \
rm -rf /var/cache/dnf /tmp/gitlab-deps
USER user:user
......
......@@ -11,3 +11,19 @@ The default entry point is the server wrapper.
podman run --read-only -p 3535 -v $(pwd)/data:/var/lib/gitlab-deps:rw,Z -v $(pwd)/token:/secrets/gitlab-token:ro,Z -e PROJECT_REGEXP='^immerda/.*' -e GITLAB_URL=https://code.immerda.ch -e GITLAB_TOKEN_FILE=/secrets/gitlab-token --userns=keep-id -it
See upstream documentation for usage.
## Cron Job
Execute the following script as cron job:
/usr/local/bin/gitlab-deps-cron
This refreshes all the projects and adds to each project we know of a hook.
## Adding hooks
You can manually add hooks by running:
echo immerda/container-images/base | gitlab-deps set-hooks --token-file /secrets/gitlab-token --webhook-auth-token $WEBHOOK_AUTH_TOKEN --hook-url https://container-deps.code.immerda.ch
This might be required if a project is not known through the dependencies, like the base images above since they have nothing they depend on.
#!/bin/bash -xe
/usr/local/sbin/update-gitlab-deps --no-reload
cat /var/lib/gitlab-deps/deps.list | cut -d: -f 1 | gitlab-deps set-hooks --token-file /secrets/gitlab-token --webhook-auth-token $WEBHOOK_AUTH_TOKEN --hook-url $HOOK_URL
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment