@@ -0,0 +1,1217 @@
+import requests%0Aimport json%0Aimport os%0A%0Aheaders = %7B%0A    %22Content-type%22: %22application/json%22,%0A    %22Accept%22: %22application/vnd.github.v3+json%22,%0A    %22Authorization%22: os.environ.get('GITHUB_BASIC_TOKEN')%0A%7D%0A%0Apayload = %7B%0A    %22name%22: %22jenkins%22,%0A    %22active%22: True,%0A    %22type%22: %22Repository%22,%0A    %22events%22: %5B%0A        %22push%22,%0A        %22pull_request%22%0A    %5D,%0A    %22config%22: %7B%0A        %22jenkins_hook_url%22: %22https://ci.gravitee.io/github-webhook/%22%0A    %7D%0A%7D%0A%0Apage = 1%0Awhile True:%0A    r = requests.get('https://api.github.com/orgs/gravitee-io/repos?page=' + str(page), headers=headers)%0A    page += 1%0A    if len(r.json()) == 0:%0A        break%0A    for repo in r.json():%0A        print(%22%22)%0A        dirname = repo.get('name')%0A        print(%22REPOSITORY: %22, dirname)%0A        url = repo.get('url')%0A        get = requests.get(url + %22/hooks%22, headers=headers)%0A        add_jenkins_webhook = True%0A        for hook in get.json():%0A            if hook.get('name') == 'jenkins':%0A                print(%22Jenkins webhook exists : skip%22)%0A                add_jenkins_webhook = False%0A                break%0A        if add_jenkins_webhook:%0A            print(%22add webhook%22)%0A            print(requests.post(url + %22/hooks%22, data=json.dumps(payload), headers=headers))%0A

add jenkins webhook on all repositories