forked from freeipa/freeipa-pr-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·69 lines (59 loc) · 2.05 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/python3
import argparse
import logging
import sys
from tasks import logging_init_stream_handler, Build
def parse_args():
desc = 'Build FreeIPA RPMs from specified git pull-request or version.'
parser = argparse.ArgumentParser(
prog='build',
description=desc)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--pull-request', '-p',
help='Number of pull-request to build',
type=int)
group.add_argument('--version',
help='Git version (tag, commit) to build')
parser.add_argument('--template-name',
help='name of vargant template box',
required=True)
parser.add_argument('--template-version',
help='version of vargant template box',
required=True)
parser.add_argument('--url-only', '-u',
help='Disable stdout logging and only print job URL',
action='store_true',
default=False)
parser.add_argument('--repo', '-r',
help='URL to git repository to use (FreeIPA github is default)')
parser.add_argument('--no-destroy',
help='Keep VMs running',
action='store_true',
default=False)
parser.add_argument('--timeout',
help='Time in seconds, after which the task will be aborted',
default=None)
return parser.parse_args()
def main():
args = parse_args()
git_repo = None
git_refspec = None
git_version = None
if args.repo:
git_repo = args.repo
if args.pull_request:
git_refspec = 'pull/{pr}/head'.format(pr=args.pull_request)
if args.version:
git_version = args.version
logging_init_stream_handler(noout=args.url_only)
template = {'name': args.template_name,
'version': args.template_version}
job = Build(template, git_refspec=git_refspec, git_version=git_version,
git_repo=git_repo, no_destroy=args.no_destroy,
timeout=args.timeout)
job()
if args.url_only:
print(job.remote_url)
sys.exit(job.returncode)
if __name__ == '__main__':
main()