1
0
mirror of https://github.com/firstBitMarksistskaya/jenkins-lib.git synced 2025-03-18 21:27:53 +02:00

Запуск синтаксического контроля

This commit is contained in:
Nikita Gryzlov 2020-04-17 12:01:43 +03:00
parent 40fc1b4cc8
commit 66ac4b10c9
No known key found for this signature in database
GPG Key ID: C1EAE411FEF0BF2F
9 changed files with 128 additions and 11 deletions

@ -9,5 +9,23 @@
"sonarQubeInstallation": "",
"useSonarScannerFromPath": true,
"sonarScannerToolName": "sonar-scanner"
},
"syntaxCheck": {
"enabled": false,
"groupErrorsByMetadata": true,
"pathToJUnitReport": "./build/out/jUnit/syntax.xml",
"checkModes": [
"-ThinClient",
"-WebClient",
"-Server",
"-ExtendedModulesCheck",
"-IncorrectReferences",
"-UnreferenceProcedures",
"-HandlersExistence",
"-EmptyHandlers",
"-CheckUseModality",
"-CheckUseSynchronousCalls",
"-DistributiveModules"
]
}
}

@ -43,6 +43,32 @@
"description" : "Имя настроенной утилиты sonar-scanner.\nПрименяется, если useSonarScannerFromPath установлено в false."
}
}
},
"syntaxCheck" : {
"type" : "object",
"id" : "urn:jsonschema:ru:pulsar:jenkins:library:configuration:SyntaxCheckOptions",
"description" : "Настройки синтаксического контроля",
"properties" : {
"enabled" : {
"type" : "boolean",
"description" : "Синтаксический контроль включен"
},
"pathToJUnitReport" : {
"type" : "string",
"description" : "Путь к файлу отчета jUnit"
},
"groupErrorsByMetadata" : {
"type" : "boolean",
"description" : "Группировать выявленные ошибки по объектам метаданных"
},
"checkModes" : {
"type" : "array",
"description" : "Режимы проверки конфигурации",
"items" : {
"type" : "string"
}
}
}
}
}
}

@ -34,7 +34,8 @@ class ConfigurationReader implements Serializable {
) {
def nonMergeableSettings = Arrays.asList(
"secrets",
"sonarQubeOptions"
"sonarQubeOptions",
"syntaxCheckOptions"
).toSet()
mergeObjects(baseConfiguration, configurationToMerge, nonMergeableSettings)

@ -17,6 +17,10 @@ class JobConfiguration implements Serializable {
@JsonPropertyDescription("Настройки анализа SonarQube")
SonarQubeOptions sonarQubeOptions;
@JsonProperty("syntaxCheck")
@JsonPropertyDescription("Настройки синтаксического контроля")
SyntaxCheckOptions syntaxCheckOptions;
@Override
@NonCPS
String toString() {
@ -24,6 +28,7 @@ class JobConfiguration implements Serializable {
"v8version='" + v8version + '\'' +
", secrets=" + secrets +
", sonarQubeOptions=" + sonarQubeOptions +
", syntaxCheckOptions=" + syntaxCheckOptions +
'}';
}
}

@ -0,0 +1,32 @@
package ru.pulsar.jenkins.library.configuration
import com.cloudbees.groovy.cps.NonCPS
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonPropertyDescription
@JsonIgnoreProperties(ignoreUnknown = true)
class SyntaxCheckOptions implements Serializable {
@JsonPropertyDescription("Синтаксический контроль включен")
boolean enabled
@JsonPropertyDescription("Путь к файлу отчета jUnit")
String pathToJUnitReport
@JsonPropertyDescription("Группировать выявленные ошибки по объектам метаданных")
boolean groupErrorsByMetadata;
@JsonPropertyDescription("Режимы проверки конфигурации")
String[] checkModes;
@Override
@NonCPS
String toString() {
return "SyntaxCheckOptions{" +
"enabled=" + enabled +
", pathToJUnitReport='" + pathToJUnitReport + '\'' +
", groupErrorsByMetadata=" + groupErrorsByMetadata +
", checkModes=" + checkModes +
'}';
}
}

@ -36,6 +36,7 @@ class ConfigurationReaderTest {
.hasFieldOrPropertyWithValue("storage", "1234")
.hasFieldOrPropertyWithValue("storagePath", "UNKNOWN_ID")
;
assertThat(jobConfiguration.getSyntaxCheckOptions().getCheckModes()).hasSize(1);
}
}

@ -2,5 +2,9 @@
"v8version": "8.3.14.1944",
"secrets": {
"storage": "1234"
},
"syntaxCheck": {
"enabled": true,
"checkModes": ["-ThinClient"]
}
}

@ -69,16 +69,7 @@ void call() {
parallel {
stage('Синтаксический контроль') {
steps {
printLocation()
installLocalDependencies()
unzipInfobase()
// Запуск синтакс-проверки
cmd("oscript_modules/bin/vrunner syntax-check --settings tools/vrunner.json", true)
junit allowEmptyResults: true, testResults: 'build/out/junitsyntax.xml'
syntaxCheck config
}
}

39
vars/syntaxCheck.groovy Normal file

@ -0,0 +1,39 @@
import hudson.FilePath
import ru.pulsar.jenkins.library.configuration.JobConfiguration
import ru.pulsar.jenkins.library.ioc.ContextRegistry
def call(JobConfiguration config) {
ContextRegistry.registerDefaultContext(this)
printLocation()
def options = config.syntaxCheckOptions
if (!options.enabled) {
echo("Syntax-check step is disabled")
return
}
installLocalDependencies()
unzipInfobase()
def junitPath = new FilePath(new File(options.pathToJUnitReport))
junitPath.mkdirs()
String command = "oscript_modules/bin/vrunner syntax-check --ibconnection \"/F./build/ib\""
if (options.groupErrorsByMetadata) {
command += " --groupbymetadata"
}
command += " --junitpath " + options.pathToJUnitReport;
command += " --mode " + options.checkModes.join(" ")
// Запуск синтакс-проверки
cmd(command, true)
junit allowEmptyResults: true, testResults: options.pathToJUnitReport
}