add webhook password

This commit is contained in:
Muzahid 2022-03-11 21:21:16 +05:30
parent d847415a41
commit afb9fe2235
Signed by: cis-muzahid
GPG Key ID: 1DC85E7D3AB613EA
1 changed files with 8 additions and 5 deletions

View File

@ -4,14 +4,11 @@ import requests
import re
token = "abc"
request_data = {
"project": "testproject",
"comments": "testcomment",
}
request_headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "text/plain",
}
ty = "/change_hook/base"
path =".buildbot"
@ -97,10 +94,15 @@ def _get_dockerfile_contents(jobname):
return res + dockerfile_extra_contents[os_codename]
def trigger_child_hooks(buildbotUrl: str, repository, branch, directory=".buildbot"):
def trigger_child_hooks(buildbotUrl: str, repository, branch, directory=".buildbot", secret):
request_url = buildbotUrl + ty
# List all jobs in the directory
jobs = list_jobs(directory)
request_headers = {
"Content-Type": "application/x-www-form-urlencoded",
'Authorization': f'token {secret}',
"Accept": "text/plain",
}
# Check if build.sh or test.sh exists in each of the jobs
for job in jobs:
@ -122,4 +124,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)