Skip to content

Commit 6ebd795

Browse files
committed
Update for moving index.html for GitLab into html_reports folder so it can be archived
1 parent ded1f85 commit 6ebd795

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

create_index_html.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,26 @@ def getReportName(filename):
5757

5858
return reportName, reportType
5959

60-
def create_index_html(mpName):
60+
usingGitLabCI = False
61+
62+
def create_index_html(mpName, isGitLab = False):
6163
import pathlib
6264
from vector.apps.DataAPI.vcproject_api import VCProjectApi
6365
from vector.apps.ReportBuilder.custom_report import CustomReport
6466

67+
global usingGitLabCI
68+
usingGitLabCI = isGitLab
69+
6570
api = VCProjectApi(mpName)
6671
# Set custom report directory to the where this script was
6772
# found. Must contain sections/index_section.py
6873
rep_path = pathlib.Path(__file__).parent.resolve()
69-
output_file="index.html"
74+
75+
if usingGitLabCI:
76+
output_file="html_reports/index.html"
77+
else:
78+
output_file="index.html"
79+
7080
CustomReport.report_from_api(
7181
api=api,
7282
title="HTML Reports",
@@ -105,6 +115,9 @@ def create_index_html_body ():
105115

106116
reportName, reportType = getReportName(html_file_name)
107117

118+
if usingGitLabCI:
119+
html_file_name = os.path.join("..", html_file_name)
120+
108121
if reportType == 1:
109122
indEnvFullEntries.append((reportName,html_file_name))
110123
elif reportType == 2:

vcast_exec.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,48 @@
5050
from vcast_utils import checkVectorCASTVersion, dump
5151
import generate_sonarqube_testresults
5252

53+
from enum import Enum
54+
55+
class CITool(Enum):
56+
JENKINS = "Jenkins"
57+
GITLAB = "GitLab CI"
58+
AZURE = "Azure Pipelines"
59+
GITHUB = "GitHub Actions"
60+
CIRCLECI = "CircleCI"
61+
TRAVIS = "Travis CI"
62+
BITBUCKET = "Bitbucket Pipelines"
63+
TEAMCITY = "TeamCity"
64+
BAMBOO = "Bamboo"
65+
UNKNOWN = "Unknown CI/CD"
66+
5367
class VectorCASTExecute(object):
68+
69+
def detect_ci_tool(self):
70+
if "JENKINS_URL" in os.environ:
71+
self.ciTool = CITool.JENKINS
72+
elif "GITLAB_CI" in os.environ:
73+
self.ciTool = CITool.GITLAB
74+
elif "AZURE_PIPELINES" in os.environ or "BUILD_SOURCEVERSION" in os.environ:
75+
self.ciTool = CITool.AZURE
76+
elif "GITHUB_ACTIONS" in os.environ:
77+
self.ciTool = CITool.GITHUB
78+
elif "CIRCLECI" in os.environ:
79+
self.ciTool = CITool.CIRCLECI
80+
elif "TRAVIS" in os.environ:
81+
self.ciTool = CITool.TRAVIS
82+
elif "BITBUCKET_BUILD_NUMBER" in os.environ:
83+
self.ciTool = CITool.BITBUCKET
84+
elif "TEAMCITY_VERSION" in os.environ:
85+
self.ciTool = CITool.TEAMCITY
86+
elif "BAMBOO_BUILDNUMBER" in os.environ:
87+
self.ciTool = CITool.BAMBOO
88+
else:
89+
self.ciTool = CITool.UNKNOWN
5490

5591
def __init__(self, args):
5692

93+
self.detect_ci_tool()
94+
5795
# setup default values
5896
self.azure = args.azure
5997
self.gitlab = args.gitlab
@@ -202,7 +240,7 @@ def generateIndexHtml(self):
202240
htmlReportList.append(report)
203241

204242
from create_index_html import create_index_html
205-
create_index_html(self.FullMP)
243+
create_index_html(self.FullMP, self.ciTool == CITool.GITLAB)
206244

207245
def runJunitMetrics(self):
208246
print("Creating JUnit Metrics")
@@ -298,7 +336,6 @@ def runReports(self):
298336
self.needIndexHtml = True
299337

300338
def generateTestCaseMgtRpt(self):
301-
print("generating tcmrs")
302339
if not os.path.exists("management"):
303340
os.makedirs("management")
304341
else:

0 commit comments

Comments
 (0)