summaryrefslogtreecommitdiff
path: root/jenkins_kernel_ci_bundle
blob: 0f2d8ba81fc938719fd65dd5fc75ee6de36889dd (plain)
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
#!/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.name": os.getenv("KERNEL_NAME", "unknown"),
                               "target.device_type": os.getenv("BOARD_TYPE", "unknown"),
                               "kernel.git_log_info": os.getenv("GIT_LOG", "unknown"),
                               "kernel.config":  os.getenv('KERNEL_CONFIG', 'unknown'),
                               "kernel.git_branch_name": os.getenv('KERNEL_BRANCH', 'unknown'),
                               "kernel.git_describe_info": os.getenv('KERNEL_VERSION','unknown'),
                               "build.id": os.getenv('BUILD_ID', 'unknown'),
                               "kernel.gitweb_url":    os.getenv('GIT_WEB_URL', 'unknown'),
                               "kernel.build_url":  os.getenv('KERNEL_BUILD_URL', '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'))
    timestamp=os.getenv('HWPACK_BUILD_DATE')
    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)