-
Notifications
You must be signed in to change notification settings - Fork 144
/
osg-wn-nightly-build
executable file
·43 lines (31 loc) · 1.35 KB
/
osg-wn-nightly-build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python
import sys
import json
import urllib
import urllib2
import argparse
import urlparse
if '/usr/libexec/singularity/python' not in sys.path:
sys.path.append('/usr/libexec/singularity/python')
import docker.api
def main():
parser = argparse.ArgumentParser(description="Tool for triggering automated builds in Docker")
parser.add_argument("-t", "--tokenfile", help="Path to file containing DockerHub security token", dest="tokenfile", required=True)
args = parser.parse_args()
with open(args.tokenfile, "r") as fp:
token = fp.read().strip()
all_tags = [i for i in docker.api.get_tags(namespace="opensciencegrid", repo_name="osg-wn") if (('testing' in i) or ('devel' in i))]
token_escaped = urllib.quote(token)
url = urlparse.urljoin("https://registry.hub.docker.com/u/opensciencegrid/osg-wn/trigger/", token_escaped) + "/"
#handler=urllib2.HTTPSHandler(debuglevel=1)
#opener = urllib2.build_opener(handler)
#urllib2.install_opener(opener)
for tag in all_tags:
print "Requesting rebuild of tag", tag
request_data = json.dumps({"docker_tag": tag})
req = urllib2.Request(url, request_data, {"Content-Type": "application/json", "Content-Length": len(request_data)})
f = urllib2.urlopen(req)
print f.read()
f.close()
if __name__ == '__main__':
main()