|
50 | 50 | from vcast_utils import checkVectorCASTVersion, dump |
51 | 51 | import generate_sonarqube_testresults |
52 | 52 |
|
| 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 | + |
53 | 67 | 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 |
54 | 90 |
|
55 | 91 | def __init__(self, args): |
56 | 92 |
|
| 93 | + self.detect_ci_tool() |
| 94 | + |
57 | 95 | # setup default values |
58 | 96 | self.azure = args.azure |
59 | 97 | self.gitlab = args.gitlab |
@@ -202,7 +240,7 @@ def generateIndexHtml(self): |
202 | 240 | htmlReportList.append(report) |
203 | 241 |
|
204 | 242 | from create_index_html import create_index_html |
205 | | - create_index_html(self.FullMP) |
| 243 | + create_index_html(self.FullMP, self.ciTool == CITool.GITLAB) |
206 | 244 |
|
207 | 245 | def runJunitMetrics(self): |
208 | 246 | print("Creating JUnit Metrics") |
@@ -298,7 +336,6 @@ def runReports(self): |
298 | 336 | self.needIndexHtml = True |
299 | 337 |
|
300 | 338 | def generateTestCaseMgtRpt(self): |
301 | | - print("generating tcmrs") |
302 | 339 | if not os.path.exists("management"): |
303 | 340 | os.makedirs("management") |
304 | 341 | else: |
|
0 commit comments