You've already forked jenkins-lib
mirror of
https://github.com/firstBitMarksistskaya/jenkins-lib.git
synced 2025-08-25 20:09:25 +02:00
Merge pull request #148 from ovcharenko-di/feature/allure-syntax-check
This commit is contained in:
@@ -36,7 +36,7 @@ val junitVersion = "5.11.0"
|
|||||||
val spockVersion = "1.3-groovy-2.4"
|
val spockVersion = "1.3-groovy-2.4"
|
||||||
val groovyVersion = "2.4.21"
|
val groovyVersion = "2.4.21"
|
||||||
val slf4jVersion = "2.0.16"
|
val slf4jVersion = "2.0.16"
|
||||||
val jsonschemaVersion = "4.36.0"
|
val jsonschemaVersion = "4.37.0"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("org.codehaus.groovy", "groovy-all", groovyVersion)
|
implementation("org.codehaus.groovy", "groovy-all", groovyVersion)
|
||||||
|
@@ -64,7 +64,6 @@
|
|||||||
},
|
},
|
||||||
"syntaxCheck": {
|
"syntaxCheck": {
|
||||||
"groupErrorsByMetadata": true,
|
"groupErrorsByMetadata": true,
|
||||||
"pathToJUnitReport": "./build/out/jUnit/syntax.xml",
|
|
||||||
"exceptionFile": "./tools/syntax-check-exception-file.txt",
|
"exceptionFile": "./tools/syntax-check-exception-file.txt",
|
||||||
"checkModes": [
|
"checkModes": [
|
||||||
"-ThinClient",
|
"-ThinClient",
|
||||||
@@ -79,7 +78,9 @@
|
|||||||
"-CheckUseSynchronousCalls",
|
"-CheckUseSynchronousCalls",
|
||||||
"-DistributiveModules"
|
"-DistributiveModules"
|
||||||
],
|
],
|
||||||
"vrunnerSettings": "./tools/vrunner.json"
|
"vrunnerSettings": "./tools/vrunner.json",
|
||||||
|
"publishToAllureReport": false,
|
||||||
|
"publishToJUnitReport": true
|
||||||
},
|
},
|
||||||
"smoke": {
|
"smoke": {
|
||||||
"vrunnerSettings": "./tools/vrunner.json",
|
"vrunnerSettings": "./tools/vrunner.json",
|
||||||
|
@@ -31,12 +31,12 @@
|
|||||||
"coverage" : {
|
"coverage" : {
|
||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
"description" : "Выполнять замер покрытия",
|
"description" : "Выполнять замер покрытия",
|
||||||
"default" : "false"
|
"default" : false
|
||||||
},
|
},
|
||||||
"dbgsPort" : {
|
"dbgsPort" : {
|
||||||
"type" : "integer",
|
"type" : "integer",
|
||||||
"description" : "Порт, на котором будет запущен сервер отладки для замера покрытия",
|
"description" : "Порт, на котором будет запущен сервер отладки для замера покрытия",
|
||||||
"default" : "1550"
|
"default" : 1550
|
||||||
},
|
},
|
||||||
"vrunnerSteps" : {
|
"vrunnerSteps" : {
|
||||||
"description" : "Шаги, запускаемые через vrunner.\n В каждой строке передается отдельная команда \n vrunner и ее аргументы (например, \"vanessa --settings ./tools/vrunner.json\").\n По умолчанию содержит одну команду \"vanessa --settings ./tools/vrunner.json\".\n ",
|
"description" : "Шаги, запускаемые через vrunner.\n В каждой строке передается отдельная команда \n vrunner и ее аргументы (например, \"vanessa --settings ./tools/vrunner.json\").\n По умолчанию содержит одну команду \"vanessa --settings ./tools/vrunner.json\".\n ",
|
||||||
@@ -250,12 +250,12 @@
|
|||||||
"coverage" : {
|
"coverage" : {
|
||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
"description" : "Выполнять замер покрытия",
|
"description" : "Выполнять замер покрытия",
|
||||||
"default" : "false"
|
"default" : false
|
||||||
},
|
},
|
||||||
"dbgsPort" : {
|
"dbgsPort" : {
|
||||||
"type" : "integer",
|
"type" : "integer",
|
||||||
"description" : "Порт, на котором будет запущен сервер отладки для замера покрытия",
|
"description" : "Порт, на котором будет запущен сервер отладки для замера покрытия",
|
||||||
"default" : "1550"
|
"default" : 1550
|
||||||
},
|
},
|
||||||
"publishToAllureReport" : {
|
"publishToAllureReport" : {
|
||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
@@ -378,9 +378,15 @@
|
|||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
"description" : "Группировать выявленные ошибки по объектам метаданных.\n По умолчанию включено.\n "
|
"description" : "Группировать выявленные ошибки по объектам метаданных.\n По умолчанию включено.\n "
|
||||||
},
|
},
|
||||||
"pathToJUnitReport" : {
|
"publishToAllureReport" : {
|
||||||
"type" : "string",
|
"type" : "boolean",
|
||||||
"description" : "Путь к файлу отчета jUnit\n По умолчанию содержит значение \"./build/out/jUnit/syntax.xml\"\n "
|
"description" : "Выполнять публикацию результатов в отчет Allure.\n По умолчанию выключено.\n ",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
|
"publishToJUnitReport" : {
|
||||||
|
"type" : "boolean",
|
||||||
|
"description" : "Выполнять публикацию результатов в отчет JUnit.\n По умолчанию включено.\n ",
|
||||||
|
"default": true
|
||||||
},
|
},
|
||||||
"vrunnerSettings" : {
|
"vrunnerSettings" : {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
@@ -469,12 +475,12 @@
|
|||||||
"coverage" : {
|
"coverage" : {
|
||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
"description" : "Выполнять замер покрытия",
|
"description" : "Выполнять замер покрытия",
|
||||||
"default" : "false"
|
"default" : false
|
||||||
},
|
},
|
||||||
"dbgsPort" : {
|
"dbgsPort" : {
|
||||||
"type" : "integer",
|
"type" : "integer",
|
||||||
"description" : "Порт, на котором будет запущен сервер отладки для замера покрытия",
|
"description" : "Порт, на котором будет запущен сервер отладки для замера покрытия",
|
||||||
"default" : "1550"
|
"default" : 1550
|
||||||
},
|
},
|
||||||
"publishToAllureReport" : {
|
"publishToAllureReport" : {
|
||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
|
@@ -2,16 +2,13 @@ package ru.pulsar.jenkins.library.configuration
|
|||||||
|
|
||||||
import com.cloudbees.groovy.cps.NonCPS
|
import com.cloudbees.groovy.cps.NonCPS
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription
|
import com.fasterxml.jackson.annotation.JsonPropertyDescription
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
class SyntaxCheckOptions implements Serializable {
|
class SyntaxCheckOptions implements Serializable {
|
||||||
|
|
||||||
@JsonPropertyDescription("""Путь к файлу отчета jUnit
|
|
||||||
По умолчанию содержит значение "./build/out/jUnit/syntax.xml"
|
|
||||||
""")
|
|
||||||
String pathToJUnitReport = "./build/out/jUnit/syntax.xml"
|
|
||||||
|
|
||||||
@JsonPropertyDescription("""Группировать выявленные ошибки по объектам метаданных.
|
@JsonPropertyDescription("""Группировать выявленные ошибки по объектам метаданных.
|
||||||
По умолчанию включено.
|
По умолчанию включено.
|
||||||
""")
|
""")
|
||||||
@@ -31,14 +28,27 @@ class SyntaxCheckOptions implements Serializable {
|
|||||||
""")
|
""")
|
||||||
String vrunnerSettings = "./tools/vrunner.json"
|
String vrunnerSettings = "./tools/vrunner.json"
|
||||||
|
|
||||||
|
@JsonPropertyDescription("""Выполнять публикацию результатов в отчет Allure.
|
||||||
|
По умолчанию выключено.
|
||||||
|
""")
|
||||||
|
@JsonProperty(defaultValue = "false")
|
||||||
|
boolean publishToAllureReport = false
|
||||||
|
|
||||||
|
@JsonPropertyDescription("""Выполнять публикацию результатов в отчет JUnit.
|
||||||
|
По умолчанию включено.
|
||||||
|
""")
|
||||||
|
@JsonProperty(defaultValue = "true")
|
||||||
|
boolean publishToJUnitReport = true
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NonCPS
|
@NonCPS
|
||||||
String toString() {
|
String toString() {
|
||||||
return "SyntaxCheckOptions{" +
|
return "SyntaxCheckOptions{" +
|
||||||
"pathToJUnitReport='" + pathToJUnitReport + '\'' +
|
|
||||||
", groupErrorsByMetadata=" + groupErrorsByMetadata +
|
", groupErrorsByMetadata=" + groupErrorsByMetadata +
|
||||||
", checkModes=" + checkModes +
|
", checkModes=" + checkModes +
|
||||||
", vrunnerSettings=" + vrunnerSettings +
|
", vrunnerSettings=" + vrunnerSettings +
|
||||||
'}';
|
", publishToAllureReport=" + publishToAllureReport +
|
||||||
|
", publishToJUnitReport=" + publishToJUnitReport +
|
||||||
|
'}'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,9 @@ class PublishAllure implements Serializable {
|
|||||||
if (config.stageFlags.smoke && config.smokeTestOptions.publishToAllureReport) {
|
if (config.stageFlags.smoke && config.smokeTestOptions.publishToAllureReport) {
|
||||||
safeUnstash(SmokeTest.ALLURE_STASH)
|
safeUnstash(SmokeTest.ALLURE_STASH)
|
||||||
}
|
}
|
||||||
|
if (config.stageFlags.syntaxCheck && config.syntaxCheckOptions.publishToAllureReport) {
|
||||||
|
safeUnstash(SyntaxCheck.ALLURE_STASH)
|
||||||
|
}
|
||||||
|
|
||||||
def env = steps.env()
|
def env = steps.env()
|
||||||
|
|
||||||
|
96
src/ru/pulsar/jenkins/library/steps/SyntaxCheck.groovy
Normal file
96
src/ru/pulsar/jenkins/library/steps/SyntaxCheck.groovy
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
package ru.pulsar.jenkins.library.steps
|
||||||
|
|
||||||
|
import hudson.FilePath
|
||||||
|
import ru.pulsar.jenkins.library.IStepExecutor
|
||||||
|
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.VRunner
|
||||||
|
|
||||||
|
class SyntaxCheck {
|
||||||
|
|
||||||
|
public static final String ALLURE_STASH = 'syntax-check-allure'
|
||||||
|
|
||||||
|
private final JobConfiguration config
|
||||||
|
|
||||||
|
SyntaxCheck(JobConfiguration config) {
|
||||||
|
this.config = config
|
||||||
|
}
|
||||||
|
|
||||||
|
def run() {
|
||||||
|
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
||||||
|
|
||||||
|
Logger.printLocation()
|
||||||
|
|
||||||
|
if (!config.stageFlags.syntaxCheck) {
|
||||||
|
Logger.println("Syntax-check step is disabled")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
def env = steps.env()
|
||||||
|
|
||||||
|
def options = config.syntaxCheckOptions
|
||||||
|
|
||||||
|
List<String> logosConfig = ["LOGOS_CONFIG=$config.logosConfig"]
|
||||||
|
steps.withEnv(logosConfig) {
|
||||||
|
steps.installLocalDependencies()
|
||||||
|
|
||||||
|
String junitReport = "build/out/jUnit/syntax-check/syntax-check.xml"
|
||||||
|
FilePath pathToJUnitReport = FileUtils.getFilePath("$env.WORKSPACE/$junitReport")
|
||||||
|
String junitReportDir = FileUtils.getLocalPath(pathToJUnitReport.getParent())
|
||||||
|
|
||||||
|
String allureReport = "build/out/allure/syntax-check/allure.xml"
|
||||||
|
FilePath pathToAllureReport = FileUtils.getFilePath("$env.WORKSPACE/$allureReport")
|
||||||
|
String allureReportDir = FileUtils.getLocalPath(pathToAllureReport.getParent())
|
||||||
|
|
||||||
|
String vrunnerPath = VRunner.getVRunnerPath()
|
||||||
|
String command = "$vrunnerPath syntax-check --ibconnection \"/F./build/ib\""
|
||||||
|
|
||||||
|
// Временно убрал передачу параметра.
|
||||||
|
// См. https://github.com/vanessa-opensource/vanessa-runner/issues/361
|
||||||
|
// command += " --workspace $env.WORKSPACE"
|
||||||
|
|
||||||
|
if (options.groupErrorsByMetadata) {
|
||||||
|
command += ' --groupbymetadata'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.publishToJUnitReport) {
|
||||||
|
steps.createDir(junitReportDir)
|
||||||
|
command += " --junitpath $pathToJUnitReport"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.publishToAllureReport) {
|
||||||
|
steps.createDir(allureReportDir)
|
||||||
|
command += " --allure-results2 $allureReportDir"
|
||||||
|
}
|
||||||
|
|
||||||
|
FilePath vrunnerSettings = FileUtils.getFilePath("$env.WORKSPACE/$options.vrunnerSettings")
|
||||||
|
if (vrunnerSettings.exists()) {
|
||||||
|
command += " --settings $vrunnerSettings"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!options.exceptionFile.empty && steps.fileExists(options.exceptionFile)) {
|
||||||
|
command += " --exception-file $options.exceptionFile"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.checkModes.length > 0) {
|
||||||
|
def checkModes = options.checkModes.join(" ")
|
||||||
|
command += " --mode $checkModes"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Запуск синтакс-проверки
|
||||||
|
VRunner.exec(command, true)
|
||||||
|
|
||||||
|
if (options.publishToAllureReport) {
|
||||||
|
steps.stash(ALLURE_STASH, "$allureReportDir/**", true)
|
||||||
|
steps.archiveArtifacts("$allureReportDir/**")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.publishToJUnitReport) {
|
||||||
|
steps.junit("$junitReportDir/*.xml", true)
|
||||||
|
steps.archiveArtifacts("$junitReportDir/**")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -248,12 +248,22 @@ void call() {
|
|||||||
beforeAgent true
|
beforeAgent true
|
||||||
expression { config.stageFlags.syntaxCheck }
|
expression { config.stageFlags.syntaxCheck }
|
||||||
}
|
}
|
||||||
|
stages {
|
||||||
|
stage('Распаковка ИБ') {
|
||||||
|
steps {
|
||||||
|
unzipInfobase()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Выполнение синтаксического контроля') {
|
||||||
steps {
|
steps {
|
||||||
timeout(time: config.timeoutOptions.syntaxCheck, unit: TimeUnit.MINUTES) {
|
timeout(time: config.timeoutOptions.syntaxCheck, unit: TimeUnit.MINUTES) {
|
||||||
syntaxCheck config
|
syntaxCheck config
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stage('Дымовые тесты') {
|
stage('Дымовые тесты') {
|
||||||
agent {
|
agent {
|
||||||
|
@@ -1,64 +1,12 @@
|
|||||||
import hudson.FilePath
|
|
||||||
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||||
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||||
import ru.pulsar.jenkins.library.utils.FileUtils
|
import ru.pulsar.jenkins.library.steps.SyntaxCheck
|
||||||
import ru.pulsar.jenkins.library.utils.VRunner
|
|
||||||
|
|
||||||
def call(JobConfiguration config) {
|
def call(JobConfiguration config) {
|
||||||
|
|
||||||
ContextRegistry.registerDefaultContext(this)
|
ContextRegistry.registerDefaultContext(this)
|
||||||
|
|
||||||
// TODO: Вынести в отдельный класс по аналогии с SonarScanner
|
def syntaxCheck = new SyntaxCheck(config)
|
||||||
|
syntaxCheck.run()
|
||||||
|
|
||||||
printLocation()
|
|
||||||
|
|
||||||
if (!config.stageFlags.syntaxCheck) {
|
|
||||||
echo("Syntax-check step is disabled")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
def options = config.syntaxCheckOptions
|
|
||||||
|
|
||||||
installLocalDependencies()
|
|
||||||
|
|
||||||
unzipInfobase()
|
|
||||||
|
|
||||||
FilePath pathToJUnitReport = FileUtils.getFilePath("$env.WORKSPACE/$options.pathToJUnitReport")
|
|
||||||
|
|
||||||
String outPath = pathToJUnitReport.getParent()
|
|
||||||
createDir(outPath)
|
|
||||||
|
|
||||||
String vrunnerPath = VRunner.getVRunnerPath();
|
|
||||||
String command = "$vrunnerPath syntax-check --ibconnection \"/F./build/ib\""
|
|
||||||
|
|
||||||
// Временно убрал передачу параметра.
|
|
||||||
// См. https://github.com/vanessa-opensource/vanessa-runner/issues/361
|
|
||||||
// command += " --workspace $env.WORKSPACE"
|
|
||||||
|
|
||||||
if (options.groupErrorsByMetadata) {
|
|
||||||
command += ' --groupbymetadata'
|
|
||||||
}
|
|
||||||
|
|
||||||
command += " --junitpath $pathToJUnitReport";
|
|
||||||
|
|
||||||
FilePath vrunnerSettings = FileUtils.getFilePath("$env.WORKSPACE/$options.vrunnerSettings")
|
|
||||||
if (vrunnerSettings.exists()) {
|
|
||||||
command += " --settings $vrunnerSettings";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!options.exceptionFile.empty && fileExists(options.exceptionFile)) {
|
|
||||||
command += " --exception-file $options.exceptionFile"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.checkModes.length > 0) {
|
|
||||||
def checkModes = options.checkModes.join(" ")
|
|
||||||
command += " --mode $checkModes"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Запуск синтакс-проверки
|
|
||||||
VRunner.exec(command, true)
|
|
||||||
|
|
||||||
junit allowEmptyResults: true, testResults: FileUtils.getLocalPath(pathToJUnitReport)
|
|
||||||
|
|
||||||
archiveArtifacts FileUtils.getLocalPath(pathToJUnitReport)
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user