1
0
mirror of https://github.com/firstBitMarksistskaya/jenkins-lib.git synced 2025-02-08 14:29:15 +02:00

Трансформация edt-validate в generic issue

This commit is contained in:
Nikita Gryzlov 2020-04-28 17:43:47 +03:00
parent aa8f96de70
commit fca4fe4154
No known key found for this signature in database
GPG Key ID: C1EAE411FEF0BF2F
7 changed files with 97 additions and 10 deletions

View File

@ -31,4 +31,8 @@ interface IStepExecutor {
def withEnv(List<String> strings, Closure body)
def archiveArtifacts(String path)
def stash(String name, String includes)
def unstash(String name)
}

View File

@ -78,4 +78,14 @@ class StepExecutor implements IStepExecutor {
def archiveArtifacts(String path) {
steps.archiveArtifacts path
}
@Override
def stash(String name, String includes) {
steps.stash name: name, includes: includes
}
@Override
def unstash(String name) {
steps.unstash name
}
}

View File

@ -21,7 +21,7 @@ class EdtValidate implements Serializable {
Logger.printLocation()
if (!config.stageFlags.edtValidate) {
steps.echo("EDT validate step is disabled")
Logger.println("EDT validate step is disabled")
return
}
@ -54,5 +54,6 @@ class EdtValidate implements Serializable {
}
steps.archiveArtifacts(resultFileRelative)
steps.stash('edt-validate', resultFileRelative)
}
}

View File

@ -0,0 +1,48 @@
package ru.pulsar.jenkins.library.steps
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.Logger
class ResultsTransformer implements Serializable {
private final JobConfiguration config;
private final String rootDir
ResultsTransformer(JobConfiguration config, String rootDir = 'src/cf') {
this.config = config
this.rootDir = rootDir
}
def run() {
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
Logger.printLocation()
if (!config.stageFlags.sonarqube) {
Logger.println("No transform is needed.")
return
}
def env = steps.env();
if (!config.stageFlags.edtValidate) {
Logger.println("EDT validation is disabled. No transform is needed.")
return
}
steps.unstash('edt-validate')
Logger.println("Конвертация результата EDT в Generic Issue")
def genericIssueRelative = "build/out/edt-generic-issue.json"
def edtValidateFile = "$env.WORKSPACE/build/out/edt-validate.xml"
def genericIssueFile = "$env.WORKSPACE/$genericIssueRelative"
steps.cmd("stebi convert $edtValidateFile $genericIssueFile $rootDir")
steps.archiveArtifacts(genericIssueRelative)
steps.stash('edt-generic-issue', genericIssueRelative)
}
}

View File

@ -44,6 +44,11 @@ class SonarScanner implements Serializable {
sonarCommand += " -Dsonar.projectVersion=$configurationVersion"
}
if (config.stageFlags.edtValidate) {
steps.unstash("edt-generic-issue")
sonarCommand += " -Dsonar.externalIssuesReportPaths=build/out/edt-generic-issue.json"
}
def sonarQubeInstallation = config.sonarQubeOptions.sonarQubeInstallation
if (sonarQubeInstallation == '') {
sonarQubeInstallation = null

View File

@ -35,15 +35,6 @@ void call() {
}
}
stage('SonarQube') {
agent {
label 'sonar'
}
steps {
sonarScanner config
}
}
stage('1C') {
agent {
label agent1C
@ -89,6 +80,24 @@ void call() {
}
}
}
stage('Трансформация результатов') {
agent {
label 'oscript'
}
steps {
transform config
}
}
}
}
stage('SonarQube') {
agent {
label 'sonar'
}
steps {
sonarScanner config
}
}
}

10
vars/transform.groovy Normal file
View File

@ -0,0 +1,10 @@
import ru.pulsar.jenkins.library.configuration.JobConfiguration
import ru.pulsar.jenkins.library.ioc.ContextRegistry
import ru.pulsar.jenkins.library.steps.ResultsTransformer
def call(JobConfiguration config) {
ContextRegistry.registerDefaultContext(this)
def transformer = new ResultsTransformer(config)
transformer.run()
}