From e0bc1e94932f82f036878747128838735abaa58c Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 9 Jun 2021 22:14:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D1=87?= =?UTF-8?q?=D0=B0=20vrunner.json=20=D0=B2=20syntax-check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/globalConfiguration.json | 5 ++-- resources/schema.json | 6 ++++- .../configuration/SyntaxCheckOptions.groovy | 20 ++++++++++---- vars/syntaxCheck.groovy | 26 ++++++++++++++----- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/resources/globalConfiguration.json b/resources/globalConfiguration.json index b25868f..d0e62b6 100644 --- a/resources/globalConfiguration.json +++ b/resources/globalConfiguration.json @@ -30,7 +30,7 @@ }, "syntaxCheck": { "groupErrorsByMetadata": true, - "pathToJUnitReport": "build/out/jUnit/syntax.xml", + "pathToJUnitReport": "./build/out/jUnit/syntax.xml", "checkModes": [ "-ThinClient", "-WebClient", @@ -43,7 +43,8 @@ "-CheckUseModality", "-CheckUseSynchronousCalls", "-DistributiveModules" - ] + ], + "vrunnerSettings": "./tools/vrunner.json" }, "resultsTransform": { "removeSupport": false, diff --git a/resources/schema.json b/resources/schema.json index e964184..669178d 100644 --- a/resources/schema.json +++ b/resources/schema.json @@ -118,7 +118,7 @@ "properties" : { "pathToJUnitReport" : { "type" : "string", - "description" : "Путь к файлу отчета jUnit" + "description" : "Путь к файлу отчета jUnit\n По умолчанию содержит значение \"./build/out/junitsyntax.xml\"\n " }, "groupErrorsByMetadata" : { "type" : "boolean", @@ -130,6 +130,10 @@ "items" : { "type" : "string" } + }, + "vrunnerSettings" : { + "type" : "string", + "description" : "Путь к конфигурационному файлу vanessa-runner.\n По умолчанию содержит значение \"./tools/vrunner.json\".\n " } } }, diff --git a/src/ru/pulsar/jenkins/library/configuration/SyntaxCheckOptions.groovy b/src/ru/pulsar/jenkins/library/configuration/SyntaxCheckOptions.groovy index dc765f4..6edbf9b 100644 --- a/src/ru/pulsar/jenkins/library/configuration/SyntaxCheckOptions.groovy +++ b/src/ru/pulsar/jenkins/library/configuration/SyntaxCheckOptions.groovy @@ -7,14 +7,23 @@ import com.fasterxml.jackson.annotation.JsonPropertyDescription @JsonIgnoreProperties(ignoreUnknown = true) class SyntaxCheckOptions implements Serializable { - @JsonPropertyDescription("Путь к файлу отчета jUnit") - String pathToJUnitReport + @JsonPropertyDescription("""Путь к файлу отчета jUnit + По умолчанию содержит значение "./build/out/jUnit/syntax.xml" + """) + String pathToJUnitReport = "./build/out/jUnit/syntax.xml" - @JsonPropertyDescription("Группировать выявленные ошибки по объектам метаданных") - boolean groupErrorsByMetadata; + @JsonPropertyDescription("""Группировать выявленные ошибки по объектам метаданных. + По умолчанию включено. + """) + boolean groupErrorsByMetadata = true @JsonPropertyDescription("Режимы проверки конфигурации") - String[] checkModes; + String[] checkModes + + @JsonPropertyDescription("""Путь к конфигурационному файлу vanessa-runner. + По умолчанию содержит значение "./tools/vrunner.json". + """) + String vrunnerSettings = "./tools/vrunner.json" @Override @NonCPS @@ -23,6 +32,7 @@ class SyntaxCheckOptions implements Serializable { "pathToJUnitReport='" + pathToJUnitReport + '\'' + ", groupErrorsByMetadata=" + groupErrorsByMetadata + ", checkModes=" + checkModes + + ", vrunnerSettings=" + vrunnerSettings + '}'; } } diff --git a/vars/syntaxCheck.groovy b/vars/syntaxCheck.groovy index 3d36d25..048cb6f 100644 --- a/vars/syntaxCheck.groovy +++ b/vars/syntaxCheck.groovy @@ -1,5 +1,7 @@ +import hudson.FilePath import ru.pulsar.jenkins.library.configuration.JobConfiguration import ru.pulsar.jenkins.library.ioc.ContextRegistry +import ru.pulsar.jenkins.library.utils.FileUtils def call(JobConfiguration config) { @@ -20,27 +22,37 @@ def call(JobConfiguration config) { unzipInfobase() - def outPath = new File(options.pathToJUnitReport).getParent() + FilePath pathToJUnitReport = FileUtils.getFilePath("$env.WORKSPACE/$options.pathToJUnitReport") + + String outPath = pathToJUnitReport.getParent() createDir(outPath) - String command = "oscript_modules/bin/vrunner syntax-check --ibconnection \"/F./build/ib\"" + String command = 'oscript_modules/bin/vrunner 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 += ' --groupbymetadata' } - command += " --junitpath " + options.pathToJUnitReport; + command += " --junitpath $pathToJUnitReport"; - command += " --mode " + options.checkModes.join(" ") + FilePath vrunnerSettings = FileUtils.getFilePath("$env.WORKSPACE/$options.vrunnerSettings") + if (vrunnerSettings.exists()) { + command += " --settings $vrunnerSettings"; + } + + if (options.checkModes.length > 0) { + def checkModes = options.checkModes.join(" ") + command += " --mode $checkModes" + } // Запуск синтакс-проверки cmd(command, true) - junit allowEmptyResults: true, testResults: options.pathToJUnitReport + junit allowEmptyResults: true, testResults: FileUtils.getLocalPath(pathToJUnitReport) - archiveArtifacts options.pathToJUnitReport + archiveArtifacts FileUtils.getLocalPath(pathToJUnitReport) }