-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanual-jenkins.py
executable file
·99 lines (82 loc) · 2.76 KB
/
manual-jenkins.py
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python
import argparse
import os
import sys
import shutil
import subprocess
import build_tools
jenkins_py_script = os.path.abspath(
os.path.join(os.path.dirname(__file__), 'jenkins.py'))
def parse_args(args):
"""
Most of the parsing logic actually lives in build_tools.builders
where it can be close to the things that consume what it produces.
See build_tools.builders.argument_parsers for more info.
"""
parser = argparse.ArgumentParser(
description=' '.join([
'automates building the toolchain in the old fashion linear way']),
parents=(
[build_tools.get_parent_parser()] +
build_tools.builders.argument_parsers))
parser.add_argument(
'--no-download',
dest='download',
action='store_false',
help="Don't download & unpack dependencies.")
parser.add_argument(
'--no-upload',
'--no-deploy',
dest='deploy',
action='store_false',
help="Don't upload artifact when finished. (Implied by --no-build)")
return parser.parse_args(args)
def run_modular_build(source, platform, deploy):
command = [
sys.executable,
jenkins_py_script,
'--git-url',
source.url,
'--git-branch',
source.version,
'--platform',
platform,
'--source-dir',
source.dir
]
if not deploy:
command.append('--no-deploy')
command.append
subprocess.call(command, cwd=source.dir)
def download_deps(source):
""" get the dependencies from the source's metadata and download them
mirrors what jenkins_boostrapper does
"""
deps = build_tools.artifactory_utils.get_dependencies(
source.platform,
dependencies_dir=source.dir,
dependency_overrides={})
build_tools.artifactory_utils.download_and_extract_artifacts(
deps,
os.path.join(source.dir, "Install"),
os.path.join(source.dir, "_artifacts"))
def build_repos(args):
"""Builds each repo in the toolchain"""
# this looks at the parsed args and gives us a dict of
# kwargs to pass to each build
os.environ['NODE_LABELS'] = args.platform
build_args = build_tools.builders.extract_build_args(args)
for source in build_tools.get_toolchain(args):
if isinstance(source, build_tools.source.Repo):
if args.download:
download_deps(source)
# build is a little weirdly implemented
if args.build is None or args.build:
run_modular_build(source, args.platform, args.deploy)
if '__main__' == __name__:
parsed_args = parse_args(sys.argv[1:])
rv = build_repos(parsed_args)
if rv is build_tools.builders.SUCCESS:
sys.exit(0)
else:
sys.exit(1)