aboutsummaryrefslogtreecommitdiff
path: root/kernelci
diff options
context:
space:
mode:
authorGuillaume Tucker <guillaume.tucker@collabora.com>2019-04-24 16:14:28 +0100
committerGuillaume Tucker <guillaume.tucker@collabora.com>2019-05-03 12:59:46 +0100
commitfe9d0438eb616a099c4b03a0e9bddb59ea263369 (patch)
treefd220f4ce3e8b1b80d7244b3fd9653a89d290283 /kernelci
parent512fdcddca2d7775c277c0cf122c6cd56ffa532f (diff)
kci_build: add --json-path option to publish_kernel
Add the --json-path to the publish_kernel command to be able to specify a path where to store the build data in a local JSON file rather than submitting it to the backend server. Both can be used, if --api and --token are also provided. Signed-off-by: Guillaume Tucker <guillaume.tucker@collabora.com>
Diffstat (limited to 'kernelci')
-rw-r--r--kernelci/build.py46
1 files changed, 36 insertions, 10 deletions
diff --git a/kernelci/build.py b/kernelci/build.py
index ed85638..c05d895 100644
--- a/kernelci/build.py
+++ b/kernelci/build.py
@@ -588,7 +588,8 @@ def push_kernel(kdir, api, token, install='_install_'):
return True
-def publish_kernel(kdir, api, token, install='_install_'):
+def publish_kernel(kdir, install='_install_', api=None, token=None,
+ json_path=None):
install_path = os.path.join(kdir, install)
with open(os.path.join(install_path, 'build.json')) as f:
@@ -596,6 +597,7 @@ def publish_kernel(kdir, api, token, install='_install_'):
data = {k: bmeta[v] for k, v in {
'path': 'file_server_resource',
+ 'file_server_resource': 'file_server_resource',
'job': 'job',
'git_branch': 'git_branch',
'arch': 'arch',
@@ -605,14 +607,38 @@ def publish_kernel(kdir, api, token, install='_install_'):
'defconfig_full': 'defconfig_full',
}.iteritems()}
- headers = {
- 'Authorization': token,
- 'Content-Type': 'application/json',
- }
-
- url = urlparse.urljoin(api, '/build')
- json_data = json.dumps(data)
- resp = requests.post(url, headers=headers, data=json_data)
- resp.raise_for_status()
+ if json_path:
+ json_data = dict(data)
+ for k in ['kernel_image', 'modules', 'git_commit', 'git_url']:
+ json_data[k] = bmeta[k]
+ json_data['status'] = bmeta['build_result']
+ dtb_data = []
+ if bmeta['dtb_dir']:
+ dtb_dir = os.path.join(install_path, bmeta['dtb_dir'])
+ for root, dirs, files in os.walk(dtb_dir):
+ if root != dtb_dir:
+ rel = os.path.relpath(root, dtb_dir)
+ files = list(os.path.join(rel, dtb) for dtb in files)
+ dtb_data += files
+ json_data['dtb_dir_data'] = dtb_data
+ try:
+ with open(json_path, 'r') as json_file:
+ full_json = json.load(json_file)
+ full_json.append(json_data)
+ except Exception as e:
+ full_json = [json_data]
+ with open(json_path, 'w') as json_file:
+ json.dump(full_json, json_file)
+
+ if api and token:
+ headers = {
+ 'Authorization': token,
+ 'Content-Type': 'application/json',
+ }
+
+ url = urlparse.urljoin(api, '/build')
+ json_data = json.dumps(data)
+ resp = requests.post(url, headers=headers, data=json_data)
+ resp.raise_for_status()
return True