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
|
#!/usr/bin/env python
import sys
import json
import uuid
import os
from datetime import datetime, timedelta
from linaro_dashboard_bundle.io import DocumentIO
build_status=os.getenv('BUILD_STATUS')
gcc_cross_compiler_version = os.getenv('GCC_CROSS_COMPILER', 'unknown')
gcc_version = os.getenv('GCC_VERSION', 'unknown')
commit_time=os.getenv("COMMIT_TIME")
commit_time=commit_time.rsplit(' ', 1)[0]
commit_time=((datetime.strptime(commit_time, "%a, %d %b %Y %H:%M:%S")).strftime("%Y-%m-%dT%H:%M:%SZ"))
bundle = {
"format": "Dashboard Bundle Format 1.2",
"test_runs": [
{
"test_id": "kernel-ci",
"test_results": [ {
"test_case_id": "build-status",
"result": build_status
},],
"attributes": {
"kernel.config": os.getenv('KERNEL_CONFIG', 'unknown'),
"kernel.build_url": os.getenv('KERNEL_BUILD_URL', 'unknown'),
"kernel.git_branch_name": os.getenv('KERNEL_BRANCH', 'unknown'),
"build.id": os.getenv('BUILD_ID', 'unknown')
},
"software_context": {
"image": {
"name": os.getenv('OS_INFO', 'unknown')
},
"sources": [{
"project_name": "Linux Linaro",
"branch_vcs": "git",
"branch_url": os.getenv('KERNEL_GIT', 'git://git.linaro.org/kernel/unknown'),
"branch_revision": os.getenv('KERNEL_COMMIT', 'unknown'),
"commit_timestamp": commit_time
} ]
},
"attachments": [{
"pathname": "consoleText",
"mime_type": "text/plain",
"public_url": os.getenv('LOG', 'unknown')
},],
"time_check_performed": True,
}
]
}
def GetInHMS(seconds):
d = timedelta(seconds=seconds)
return "%02dd %02ds %02dus" % (d.days, d.seconds, d.microseconds)
if build_status != 'fail':
build_time=int(os.getenv('EXECUTION_TIME_IN_SEC'))
hwpack_filename=os.getenv('HWPACK_NAME')
timestamp=hwpack_filename.rsplit('_', 3)[1]
timestamp=((datetime.strptime(timestamp, "%Y%m%d-%H%M")).strftime("%Y-%m-%dT%H:%M:%SZ"))
bundle['test_runs'][0]['test_results'][0]['timestamp']=timestamp
bundle['test_runs'][0]['test_results'][0]['duration']=GetInHMS(build_time)
bundle['test_runs'][0]['software_context']['packages']=[{'version': gcc_version, 'name': 'gcc'},
{'version': gcc_cross_compiler_version,
'name': 'gcc-arm-linux-gnueabi'}]
bundle['test_runs'][0]['analyzer_assigned_uuid']=str(uuid.uuid1())
bundle['test_runs'][0]['analyzer_assigned_date']=datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
print DocumentIO.dumps(bundle, human_readable=True, sort_keys=True)
|