From 0e48633cb0f18d71c7191898c62748f9e54cefca Mon Sep 17 00:00:00 2001 From: Nikita Fedkin Date: Fri, 3 Dec 2021 17:02:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BF=D1=80=D0=BE=D1=89=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=84=D0=BE=D1=80=D0=BC=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B5=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jenkins/library/steps/SmokeTest.groovy | 61 +++++++++---------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/SmokeTest.groovy b/src/ru/pulsar/jenkins/library/steps/SmokeTest.groovy index 507cc7d..ead9aa0 100644 --- a/src/ru/pulsar/jenkins/library/steps/SmokeTest.groovy +++ b/src/ru/pulsar/jenkins/library/steps/SmokeTest.groovy @@ -54,40 +54,37 @@ class SmokeTest implements Serializable { command += " --xddConfig $xddConfigPath" } - if (options.publishToAllureReport || options.publishToJUnitReport) { - - command += " --reportsxunit \"%REPORTS%\"" + String junitReport = "build/out/jUnit/smoke/smoke.xml" + FilePath pathToJUnitReport = FileUtils.getFilePath("$env.WORKSPACE/$junitReport") + String junitReportDir = FileUtils.getLocalPath(pathToJUnitReport.getParent()) - String allureReportCommand = "" - if (options.publishToAllureReport) { + String allureReport = "build/out/allure/smoke/allure.xml" + FilePath pathToAllureReport = FileUtils.getFilePath("$env.WORKSPACE/$allureReport") + String allureReportDir = FileUtils.getLocalPath(pathToAllureReport.getParent()) - String allureReport = "build/out/allure/smoke/allure.xml" - FilePath pathToAllureReport = FileUtils.getFilePath("$env.WORKSPACE/$allureReport") - String allureReportDir = FileUtils.getLocalPath(pathToAllureReport.getParent()) + StringJoiner reportsConfigConstructor = new StringJoiner(";") - steps.createDir(allureReportDir) + if (options.publishToJUnitReport) { + steps.createDir(junitReportDir) - allureReportCommand = "ГенераторОтчетаAllureXMLВерсия2{$allureReport}" + String junitReportCommand = "ГенераторОтчетаJUnitXML{$junitReport}" - } - - String junitReportCommand = "" - if (options.publishToJUnitReport) { - - String junitReport = "build/out/jUnit/smoke/smoke.xml" - FilePath pathToJUnitReport = FileUtils.getFilePath("$env.WORKSPACE/$junitReport") - String junitReportDir = FileUtils.getLocalPath(pathToJUnitReport.getParent()) - - steps.createDir(junitReportDir) - - junitReportCommand = "ГенераторОтчетаJUnitXML{$junitReport}" - } - - def commandsList = [allureReportCommand, junitReportCommand] - commandsList.removeAll([""]) - def reportsCommand = commandsList.join(";") - command.replace("%REPORTS%", reportsCommand) + reportsConfigConstructor.add(junitReportCommand) } + + if (options.publishToAllureReport) { + steps.createDir(allureReportDir) + + String allureReportCommand = "ГенераторОтчетаAllureXMLВерсия2{$allureReport}" + + reportsConfigConstructor.add(allureReportCommand) + } + + if (reportsConfigConstructor.length() > 0) { + String reportsConfig = reportsConfigConstructor.toString() + command += " --reportsxunit \"$reportsConfig\"" + } + if (steps.isUnix()) { command = command.replace(';', '\\;') } @@ -107,13 +104,15 @@ class SmokeTest implements Serializable { VRunner.exec(command) } - steps.stash(SMOKE_ALLURE_STASH, "$allureReportDir/**", true) + if (options.publishToAllureReport) { + steps.stash(SMOKE_ALLURE_STASH, "$allureReportDir/**", true) + steps.archiveArtifacts("$allureReportDir/**") + } if (options.publishToJUnitReport) { steps.junit("$junitReportDir/*.xml", true) + steps.archiveArtifacts("$junitReportDir/**") } - steps.archiveArtifacts("$junitReportDir/**") - steps.archiveArtifacts("$allureReportDir/**") } }