1
0
mirror of https://github.com/firstBitMarksistskaya/jenkins-lib.git synced 2024-12-04 10:34:42 +02:00

Упрощение сборки данных дымовых тестов

This commit is contained in:
Nikita Fedkin 2022-05-20 20:48:03 +03:00
parent df0c3f364d
commit b8af950896
No known key found for this signature in database
GPG Key ID: E7AE91471C6FFE04
2 changed files with 41 additions and 6 deletions

View File

@ -6,6 +6,7 @@ import ru.pulsar.jenkins.library.configuration.JobConfiguration
import ru.pulsar.jenkins.library.ioc.ContextRegistry
import ru.pulsar.jenkins.library.utils.FileUtils
import ru.pulsar.jenkins.library.utils.Logger
import ru.pulsar.jenkins.library.utils.StringJoiner
import ru.pulsar.jenkins.library.utils.VRunner
class SmokeTest implements Serializable {
@ -61,14 +62,14 @@ class SmokeTest implements Serializable {
FilePath pathToAllureReport = FileUtils.getFilePath("$env.WORKSPACE/$allureReport")
String allureReportDir = FileUtils.getLocalPath(pathToAllureReport.getParent())
StringBuilder reportsConfigConstructor = new StringBuilder()
StringJoiner reportsConfigConstructor = new StringJoiner(";")
if (options.publishToJUnitReport) {
steps.createDir(junitReportDir)
String junitReportCommand = "ГенераторОтчетаJUnitXML{$junitReport}"
reportsConfigConstructor.append(junitReportCommand)
reportsConfigConstructor.add(junitReportCommand)
}
if (options.publishToAllureReport) {
@ -76,10 +77,7 @@ class SmokeTest implements Serializable {
String allureReportCommand = "ГенераторОтчетаAllureXMLВерсия2{$allureReport}"
if (reportsConfigConstructor.length() > 0) {
reportsConfigConstructor.append(';')
}
reportsConfigConstructor.append(allureReportCommand)
reportsConfigConstructor.add(allureReportCommand)
}
if (reportsConfigConstructor.length() > 0) {

View File

@ -0,0 +1,37 @@
package ru.pulsar.jenkins.library.utils
class StringJoiner implements Serializable {
private final String delimiter
private StringBuilder value
StringJoiner(CharSequence delimiter) {
this.delimiter = delimiter
}
StringJoiner add(CharSequence newElement) {
prepareBuilder().append(newElement)
return this
}
int length() {
return (value != null ? value.length() : 0)
}
@Override
String toString() {
if (value == null) {
return ""
} else {
return value.toString()
}
}
private StringBuilder prepareBuilder() {
if (value != null) {
value.append(delimiter)
} else {
value = new StringBuilder()
}
return value
}
}