diff --git a/resources/globalConfiguration.json b/resources/globalConfiguration.json index 87d1e6a..6f2b15a 100644 --- a/resources/globalConfiguration.json +++ b/resources/globalConfiguration.json @@ -6,7 +6,8 @@ }, "stages": { "sonarqube": false, - "syntaxCheck": false + "syntaxCheck": false, + "edtValidate": false }, "sonarqube": { "sonarQubeInstallation": "", diff --git a/resources/schema.json b/resources/schema.json index 7ae4537..8389fc7 100644 --- a/resources/schema.json +++ b/resources/schema.json @@ -33,6 +33,10 @@ "syntaxCheck" : { "type" : "boolean", "description" : "Синтаксический контроль включен" + }, + "edtValidate" : { + "type" : "boolean", + "description" : "Валидация EDT включена" } } }, diff --git a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy index 6cb051f..fb23f30 100644 --- a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy @@ -25,4 +25,6 @@ interface IStepExecutor { void withSonarQubeEnv(String installationName, Closure body) EnvironmentAction env() + + void createDir(String path) } \ No newline at end of file diff --git a/src/ru/pulsar/jenkins/library/StepExecutor.groovy b/src/ru/pulsar/jenkins/library/StepExecutor.groovy index b38f5ce..c9b08e6 100644 --- a/src/ru/pulsar/jenkins/library/StepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/StepExecutor.groovy @@ -61,4 +61,9 @@ class StepExecutor implements IStepExecutor { EnvironmentAction env() { return steps.env } + + @Override + void createDir(String path) { + steps.createDir(path) + } } diff --git a/src/ru/pulsar/jenkins/library/configuration/StageFlags.groovy b/src/ru/pulsar/jenkins/library/configuration/StageFlags.groovy index ec1fcab..d454ee5 100644 --- a/src/ru/pulsar/jenkins/library/configuration/StageFlags.groovy +++ b/src/ru/pulsar/jenkins/library/configuration/StageFlags.groovy @@ -12,12 +12,16 @@ class StageFlags implements Serializable { @JsonPropertyDescription("Синтаксический контроль включен") boolean syntaxCheck + @JsonPropertyDescription("Валидация EDT включена") + boolean edtValidate + @Override @NonCPS String toString() { return "StageFlags{" + - "sonarQube=" + sonarqube + + "sonarqube=" + sonarqube + ", syntaxCheck=" + syntaxCheck + + ", edtValidate=" + edtValidate + '}'; } } diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy new file mode 100644 index 0000000..7c8b104 --- /dev/null +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -0,0 +1,51 @@ +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 EdtValidate implements Serializable { + + private final JobConfiguration config; + private final String rootDir + + EdtValidate(JobConfiguration config, String rootDir = 'src/cf') { + this.config = config + this.rootDir = rootDir + } + + def run() { + IStepExecutor steps = ContextRegistry.getContext().getStepExecutor() + + Logger.printLocation() + + if (!config.stageFlags.edtValidate) { + steps.echo("EDT validate step is disabled") + return + } + + def env = steps.env(); + + def projectDir = "$env.WORKSPACE/build/project" + def workspaceDir = "$env.WORKSPACE/build/workspace" + def resultFile = "$env.WORKSPACE/build/edt-validate.xml" + def configurationRoot = new File(env.WORKSPACE, rootDir).getAbsolutePath() + + steps.createDir(projectDir) + steps.createDir(workspaceDir) + steps.createDir(new File(resultFile).getParent()) + + + Logger.println("Конвертация исходников из формата конфигуратора в формат EDT") + + def ringCommand = "ring edt workspace import --configuration-files '$configurationRoot' --project '$projectDir' --workspace-location '$workspaceDir'" + steps.cmd(ringCommand) + + Logger.println("Выполнение валидации EDT") + + env.RING_OPTS = '-Dfile.encoding=UTF-8 -Dosgi.nl=ru' + ringCommand = "ring edt workspace validate --workspace-location '$workspaceDir' --file '$resultFile' --project '$projectDir'" + steps.cmd(ringCommand) + } +} diff --git a/vars/createDir.groovy b/vars/createDir.groovy new file mode 100644 index 0000000..56e83da --- /dev/null +++ b/vars/createDir.groovy @@ -0,0 +1,3 @@ +def call(String path) { + dir(path) { echo '' } +} diff --git a/vars/edtValidate.groovy b/vars/edtValidate.groovy new file mode 100644 index 0000000..679acc8 --- /dev/null +++ b/vars/edtValidate.groovy @@ -0,0 +1,10 @@ +import ru.pulsar.jenkins.library.configuration.JobConfiguration +import ru.pulsar.jenkins.library.ioc.ContextRegistry +import ru.pulsar.jenkins.library.steps.EdtValidate + +def call(JobConfiguration config, String rootDir = 'src/cf') { + ContextRegistry.registerDefaultContext(this) + + def edtValidate = new EdtValidate(config, rootDir) + edtValidate.run() +} diff --git a/vars/pipeline1C.groovy b/vars/pipeline1C.groovy index 7a178d2..b2c1f32 100644 --- a/vars/pipeline1C.groovy +++ b/vars/pipeline1C.groovy @@ -67,6 +67,15 @@ void call() { stage('Проверка качества') { parallel { + stage('EDT контроль') { + agent { + label 'edt' + } + steps { + edtValidate config + } + } + stage('Синтаксический контроль') { steps { syntaxCheck config diff --git a/vars/syntaxCheck.groovy b/vars/syntaxCheck.groovy index 047329a..3d36d25 100644 --- a/vars/syntaxCheck.groovy +++ b/vars/syntaxCheck.groovy @@ -21,7 +21,7 @@ def call(JobConfiguration config) { unzipInfobase() def outPath = new File(options.pathToJUnitReport).getParent() - dir(outPath) { echo '' } + createDir(outPath) String command = "oscript_modules/bin/vrunner syntax-check --ibconnection \"/F./build/ib\""