From 83444728f33abe08271ccc9d1d00991baef8d4d7 Mon Sep 17 00:00:00 2001 From: Muzahid Date: Fri, 11 Mar 2022 21:21:16 +0530 Subject: [PATCH] add webhook password --- lib/worker_multibuild.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/worker_multibuild.py b/lib/worker_multibuild.py index 1dfdcbf..fbd10d5 100644 --- a/lib/worker_multibuild.py +++ b/lib/worker_multibuild.py @@ -1,4 +1,5 @@ -from os import listdir, walk +import os +from os import listdir from os.path import exists, isfile, join, islink, isdir import requests import re @@ -8,10 +9,6 @@ request_data = { "project": "testproject", "comments": "testcomment", } -request_headers = { - "Content-Type": "application/x-www-form-urlencoded", - "Accept": "text/plain", -} ty = "/change_hook/base" path =".buildbot" @@ -54,6 +51,11 @@ ENTRYPOINT /usr/local/bin/buildbot_entrypoint.sh "$BUILDMASTER" "$WORKERNAME" "$ """ +def get_secret(): + with open(path.join(os.environ['HOME'], "multibuild_parent_key.key"),'r') as f: + data = f.read() + return data + def list_jobs(directory=".buildbot"): """ list jobs found in a directory @@ -101,6 +103,11 @@ def trigger_child_hooks(buildbotUrl: str, repository, branch, directory=".buildb request_url = buildbotUrl + ty # List all jobs in the directory jobs = list_jobs(directory) + request_headers = { + "Content-Type": "application/x-www-form-urlencoded", + "X-Multibuild-Trigger": get_secret(), + "Accept": "text/plain", + } # Check if build.sh or test.sh exists in each of the jobs for job in jobs: @@ -122,4 +129,5 @@ def trigger_child_hooks(buildbotUrl: str, repository, branch, directory=".buildb "branch": branch, "jobname": job, } + requests.post(request_url, headers=request_headers, data=request_data)