From cc1ae0d959fa8bdb986266f86f7bc34e6e578ec6 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Mon, 27 Apr 2020 18:05:45 +0300 Subject: [PATCH 01/25] =?UTF-8?q?=D0=A1=D0=BA=D1=80=D0=BE=D0=BC=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=BF=D0=BE=D0=BF=D1=8B=D1=82=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B2=D0=B5=D1=81=D1=82=D0=B8=20EDT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/globalConfiguration.json | 3 +- resources/schema.json | 4 ++ .../jenkins/library/IStepExecutor.groovy | 2 + .../jenkins/library/StepExecutor.groovy | 5 ++ .../library/configuration/StageFlags.groovy | 6 ++- .../jenkins/library/steps/EdtValidate.groovy | 51 +++++++++++++++++++ vars/createDir.groovy | 3 ++ vars/edtValidate.groovy | 10 ++++ vars/pipeline1C.groovy | 9 ++++ vars/syntaxCheck.groovy | 2 +- 10 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy create mode 100644 vars/createDir.groovy create mode 100644 vars/edtValidate.groovy diff --git a/resources/globalConfiguration.json b/resources/globalConfiguration.json index 87d1e6a6..6f2b15ab 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 7ae4537d..8389fc70 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 6cb051fc..fb23f304 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 b38f5ce9..c9b08e6e 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 ec1fcab2..d454ee5c 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 00000000..7c8b1048 --- /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 00000000..56e83da5 --- /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 00000000..679acc8e --- /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 7a178d2d..b2c1f32d 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 047329ab..3d36d254 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\"" From 308e5e40f9465b985acdbff46aa515ed0937fda0 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Mon, 27 Apr 2020 21:17:52 +0300 Subject: [PATCH 02/25] =?UTF-8?q?=D0=A3=D1=81=D1=82=D0=B0=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20RING=5FOPTIONS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/IStepExecutor.groovy | 2 ++ src/ru/pulsar/jenkins/library/StepExecutor.groovy | 7 +++++++ .../pulsar/jenkins/library/steps/EdtValidate.groovy | 11 ++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy index fb23f304..bf96d40d 100644 --- a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy @@ -27,4 +27,6 @@ interface IStepExecutor { EnvironmentAction env() void createDir(String path) + + def withEnv(List strings, Closure body) } \ 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 c9b08e6e..e3ef72f5 100644 --- a/src/ru/pulsar/jenkins/library/StepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/StepExecutor.groovy @@ -66,4 +66,11 @@ class StepExecutor implements IStepExecutor { void createDir(String path) { steps.createDir(path) } + + @Override + def withEnv(List strings, Closure body) { + steps.withEnv(strings) { + body() + } + } } diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index 7c8b1048..60aab6f1 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -40,12 +40,17 @@ class EdtValidate implements Serializable { Logger.println("Конвертация исходников из формата конфигуратора в формат EDT") def ringCommand = "ring edt workspace import --configuration-files '$configurationRoot' --project '$projectDir' --workspace-location '$workspaceDir'" - steps.cmd(ringCommand) + + steps.withEnv(['RING_OPTS="-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru"']) { + 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) + + steps.withEnv(['RING_OPTS="-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru"']) { + steps.cmd(ringCommand) + } } } From fd4aeb4eef26d38475e92502577b27c3d4e83e04 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Tue, 28 Apr 2020 11:50:37 +0300 Subject: [PATCH 03/25] =?UTF-8?q?=D0=A1=D0=BF=D1=80=D1=8F=D1=82=D0=B0?= =?UTF-8?q?=D0=BB=20=D0=B4=D1=8B=D0=BC=D0=BE=D0=B2=D1=8B=D0=B5=20=D0=B7?= =?UTF-8?q?=D0=B0=20=D1=84=D0=BB=D0=B0=D0=B3=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/globalConfiguration.json | 3 ++- resources/schema.json | 4 ++++ .../library/configuration/StageFlags.groovy | 4 ++++ vars/pipeline1C.groovy | 6 +---- vars/smoke.groovy | 23 +++++++++++++++++++ 5 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 vars/smoke.groovy diff --git a/resources/globalConfiguration.json b/resources/globalConfiguration.json index 6f2b15ab..1b561f3a 100644 --- a/resources/globalConfiguration.json +++ b/resources/globalConfiguration.json @@ -7,7 +7,8 @@ "stages": { "sonarqube": false, "syntaxCheck": false, - "edtValidate": false + "edtValidate": false, + "smoke": false }, "sonarqube": { "sonarQubeInstallation": "", diff --git a/resources/schema.json b/resources/schema.json index 8389fc70..89d06d2c 100644 --- a/resources/schema.json +++ b/resources/schema.json @@ -37,6 +37,10 @@ "edtValidate" : { "type" : "boolean", "description" : "Валидация EDT включена" + }, + "smoke" : { + "type" : "boolean", + "description" : "Дымовые тесты включены" } } }, diff --git a/src/ru/pulsar/jenkins/library/configuration/StageFlags.groovy b/src/ru/pulsar/jenkins/library/configuration/StageFlags.groovy index d454ee5c..4aef055a 100644 --- a/src/ru/pulsar/jenkins/library/configuration/StageFlags.groovy +++ b/src/ru/pulsar/jenkins/library/configuration/StageFlags.groovy @@ -15,6 +15,9 @@ class StageFlags implements Serializable { @JsonPropertyDescription("Валидация EDT включена") boolean edtValidate + @JsonPropertyDescription("Дымовые тесты включены") + boolean smoke + @Override @NonCPS String toString() { @@ -22,6 +25,7 @@ class StageFlags implements Serializable { "sonarqube=" + sonarqube + ", syntaxCheck=" + syntaxCheck + ", edtValidate=" + edtValidate + + ", smoke=" + smoke + '}'; } } diff --git a/vars/pipeline1C.groovy b/vars/pipeline1C.groovy index b2c1f32d..5660b9cb 100644 --- a/vars/pipeline1C.groovy +++ b/vars/pipeline1C.groovy @@ -84,11 +84,7 @@ void call() { stage('Дымовые тесты') { steps { - printLocation() - - installLocalDependencies() - - unzipInfobase() + smoke config } } } diff --git a/vars/smoke.groovy b/vars/smoke.groovy new file mode 100644 index 00000000..fc204f64 --- /dev/null +++ b/vars/smoke.groovy @@ -0,0 +1,23 @@ +import ru.pulsar.jenkins.library.configuration.JobConfiguration +import ru.pulsar.jenkins.library.ioc.ContextRegistry + +def call(JobConfiguration config) { + + ContextRegistry.registerDefaultContext(this) + + // TODO: Вынести в отдельный класс по аналогии с SonarScanner + + printLocation() + + if (!config.stageFlags.smoke) { + echo("Smoke tests step is disabled") + return + } + + def options = config.syntaxCheckOptions + + installLocalDependencies() + + unzipInfobase() + +} From aa8f96de70e962578ede01d27dccbdfc265ae2fc Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Tue, 28 Apr 2020 14:03:02 +0300 Subject: [PATCH 04/25] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D1=87=D0=B5=D1=81?= =?UTF-8?q?=D1=8B=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B5=D0=B4=D1=82-?= =?UTF-8?q?=D1=88=D0=B0=D0=B3=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jenkins/library/IStepExecutor.groovy | 2 ++ .../jenkins/library/StepExecutor.groovy | 5 +++++ .../jenkins/library/steps/EdtValidate.groovy | 20 ++++++++++--------- .../jenkins/library/utils/Logger.groovy | 6 ++++++ 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy index bf96d40d..9974a908 100644 --- a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy @@ -29,4 +29,6 @@ interface IStepExecutor { void createDir(String path) def withEnv(List strings, Closure body) + + def archiveArtifacts(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 e3ef72f5..3ac48142 100644 --- a/src/ru/pulsar/jenkins/library/StepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/StepExecutor.groovy @@ -73,4 +73,9 @@ class StepExecutor implements IStepExecutor { body() } } + + @Override + def archiveArtifacts(String path) { + steps.archiveArtifacts path + } } diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index 60aab6f1..bfdae1f6 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -27,30 +27,32 @@ class EdtValidate implements Serializable { def env = steps.env(); - def projectDir = "$env.WORKSPACE/build/project" + def resultFileRelative = 'build/out/edt-validate.xml' + def projectName = 'temp' def workspaceDir = "$env.WORKSPACE/build/workspace" - def resultFile = "$env.WORKSPACE/build/edt-validate.xml" + def resultFile = "$env.WORKSPACE/$resultFileRelative" 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.withEnv(['RING_OPTS="-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru"']) { + def ringCommand = "ring edt workspace import --configuration-files '$configurationRoot' --project-name $projectName --workspace-location '$workspaceDir'" + + def ringOpts = ['_JAVA_OPTS="-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru"'] + steps.withEnv(ringOpts) { steps.cmd(ringCommand) } Logger.println("Выполнение валидации EDT") - ringCommand = "ring edt workspace validate --workspace-location '$workspaceDir' --file '$resultFile' --project '$projectDir'" + ringCommand = "ring edt workspace validate --workspace-location '$workspaceDir' --file '$resultFile' --project-name-list $projectName" - steps.withEnv(['RING_OPTS="-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru"']) { + steps.withEnv(ringOpts) { steps.cmd(ringCommand) } + + steps.archiveArtifacts(resultFileRelative) } } diff --git a/src/ru/pulsar/jenkins/library/utils/Logger.groovy b/src/ru/pulsar/jenkins/library/utils/Logger.groovy index 3d10a244..b6808ab5 100644 --- a/src/ru/pulsar/jenkins/library/utils/Logger.groovy +++ b/src/ru/pulsar/jenkins/library/utils/Logger.groovy @@ -10,4 +10,10 @@ class Logger implements Serializable { def env = steps.env(); steps.echo("Running on node $env.NODE_NAME") } + + static void println(String message) { + IStepExecutor steps = ContextRegistry.getContext().getStepExecutor() + + steps.echo(message) + } } From fca4fe415415dd86aa3273c261b15b6bfe3c5540 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Tue, 28 Apr 2020 17:43:47 +0300 Subject: [PATCH 05/25] =?UTF-8?q?=D0=A2=D1=80=D0=B0=D0=BD=D1=81=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D0=B0=D1=86=D0=B8=D1=8F=20edt-validate=20?= =?UTF-8?q?=D0=B2=20generic=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jenkins/library/IStepExecutor.groovy | 4 ++ .../jenkins/library/StepExecutor.groovy | 10 ++++ .../jenkins/library/steps/EdtValidate.groovy | 3 +- .../library/steps/ResultsTransformer.groovy | 48 +++++++++++++++++++ .../jenkins/library/steps/SonarScanner.groovy | 5 ++ vars/pipeline1C.groovy | 27 +++++++---- vars/transform.groovy | 10 ++++ 7 files changed, 97 insertions(+), 10 deletions(-) create mode 100644 src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy create mode 100644 vars/transform.groovy diff --git a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy index 9974a908..cff3f66b 100644 --- a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy @@ -31,4 +31,8 @@ interface IStepExecutor { def withEnv(List strings, Closure body) def archiveArtifacts(String path) + + def stash(String name, String includes) + + def unstash(String name) } \ 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 3ac48142..7c8f06b3 100644 --- a/src/ru/pulsar/jenkins/library/StepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/StepExecutor.groovy @@ -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 + } } diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index bfdae1f6..8e9d2e61 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -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) } } diff --git a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy new file mode 100644 index 00000000..5143f218 --- /dev/null +++ b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy @@ -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) + } +} diff --git a/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy b/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy index d437abc9..e4bc3502 100644 --- a/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy +++ b/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy @@ -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 diff --git a/vars/pipeline1C.groovy b/vars/pipeline1C.groovy index 5660b9cb..df6cdfde 100644 --- a/vars/pipeline1C.groovy +++ b/vars/pipeline1C.groovy @@ -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 } } } diff --git a/vars/transform.groovy b/vars/transform.groovy new file mode 100644 index 00000000..f054ce5c --- /dev/null +++ b/vars/transform.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.ResultsTransformer + +def call(JobConfiguration config) { + ContextRegistry.registerDefaultContext(this) + + def transformer = new ResultsTransformer(config) + transformer.run() +} \ No newline at end of file From e4d9d58825720aa77015b4669b57209efdaea999 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Tue, 28 Apr 2020 18:05:11 +0300 Subject: [PATCH 06/25] xml -> out MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit На выходе все же не xml --- src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy | 2 +- src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index 8e9d2e61..c295e306 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -27,7 +27,7 @@ class EdtValidate implements Serializable { def env = steps.env(); - def resultFileRelative = 'build/out/edt-validate.xml' + def resultFileRelative = 'build/out/edt-validate.out' def projectName = 'temp' def workspaceDir = "$env.WORKSPACE/build/workspace" def resultFile = "$env.WORKSPACE/$resultFileRelative" diff --git a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy index 5143f218..79cdd30a 100644 --- a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy +++ b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy @@ -37,7 +37,7 @@ class ResultsTransformer implements Serializable { Logger.println("Конвертация результата EDT в Generic Issue") def genericIssueRelative = "build/out/edt-generic-issue.json" - def edtValidateFile = "$env.WORKSPACE/build/out/edt-validate.xml" + def edtValidateFile = "$env.WORKSPACE/build/out/edt-validate.out" def genericIssueFile = "$env.WORKSPACE/$genericIssueRelative" steps.cmd("stebi convert $edtValidateFile $genericIssueFile $rootDir") From 0969f3916fa28f8a29ea18f7e037bb96571c902a Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 13:09:54 +0300 Subject: [PATCH 07/25] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B0=D0=BD=D0=B0=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=20=D1=8D=D1=82=D0=B0=D0=BF=D0=BE=D0=B2=20=D1=81=D0=B1=D0=BE?= =?UTF-8?q?=D1=80=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Разделены этапы трансформации в едт, валидации и трансформации результатов --- .../jenkins/library/IStepExecutor.groovy | 6 ++ .../jenkins/library/StepExecutor.groovy | 10 +++ .../jenkins/library/steps/EdtTransform.groovy | 52 +++++++++++++ .../jenkins/library/steps/EdtValidate.groovy | 29 +++---- .../library/steps/ResultsTransformer.groovy | 23 +++--- vars/edtTransform.groovy | 10 +++ vars/pipeline1C.groovy | 77 +++++++++++-------- 7 files changed, 148 insertions(+), 59 deletions(-) create mode 100644 src/ru/pulsar/jenkins/library/steps/EdtTransform.groovy create mode 100644 vars/edtTransform.groovy diff --git a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy index cff3f66b..4eac192a 100644 --- a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy @@ -35,4 +35,10 @@ interface IStepExecutor { def stash(String name, String includes) def unstash(String name) + + def zip(String dir, String zipFile) + + def zip(String dir, String zipFile, String glob) + + def unzip(String dir, String zipFile) } \ 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 7c8f06b3..e78ad47d 100644 --- a/src/ru/pulsar/jenkins/library/StepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/StepExecutor.groovy @@ -88,4 +88,14 @@ class StepExecutor implements IStepExecutor { def unstash(String name) { steps.unstash name } + + @Override + def zip(String dir, String zipFile, String glob = '') { + steps.zip dir: dir, zipFile: zipFile, glob: glob + } + + @Override + def unzip(String dir, String zipFile) { + steps.unzip dir: dir, zipFile: zipFile + } } diff --git a/src/ru/pulsar/jenkins/library/steps/EdtTransform.groovy b/src/ru/pulsar/jenkins/library/steps/EdtTransform.groovy new file mode 100644 index 00000000..a13fdb7b --- /dev/null +++ b/src/ru/pulsar/jenkins/library/steps/EdtTransform.groovy @@ -0,0 +1,52 @@ +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 EdtTransform implements Serializable { + + public static final String PROJECT_NAME = 'temp' + public static final String WORKSPACE = 'build/edt-workspace' + public static final String WORKSPACE_ZIP = 'build/edt-workspace.zip' + public static final String WORKSPACE_ZIP_STASH = 'edt-workspace-zip' + + private final JobConfiguration config; + private final String rootDir + + EdtTransform(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) { + Logger.println("EDT validate step is disabled. No transform is needed.") + return + } + + def env = steps.env(); + + def workspaceDir = "$env.WORKSPACE/$WORKSPACE" + def configurationRoot = new File(env.WORKSPACE, rootDir).getAbsolutePath() + + steps.createDir(workspaceDir) + + Logger.println("Конвертация исходников из формата конфигуратора в формат EDT") + + def ringCommand = "ring edt workspace import --configuration-files '$configurationRoot' --project-name $PROJECT_NAME --workspace-location '$workspaceDir'" + + def ringOpts = ['RING_OPTS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru'] + steps.withEnv(ringOpts) { + steps.cmd(ringCommand) + } + + steps.zip(WORKSPACE, WORKSPACE_ZIP) + steps.stash(WORKSPACE_ZIP_STASH, WORKSPACE_ZIP) + } +} diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index c295e306..6d91c15c 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -7,6 +7,9 @@ import ru.pulsar.jenkins.library.utils.Logger class EdtValidate implements Serializable { + public static final String RESULT_STASH = 'edt-validate' + public static final String RESULT_FILE = 'build/out/edt-validate.out' + private final JobConfiguration config; private final String rootDir @@ -25,35 +28,25 @@ class EdtValidate implements Serializable { return } + steps.unstash(EdtTransform.WORKSPACE_ZIP_STASH) + steps.unzip(EdtTransform.WORKSPACE_ZIP, EdtTransform.WORKSPACE) + def env = steps.env(); - def resultFileRelative = 'build/out/edt-validate.out' - def projectName = 'temp' - def workspaceDir = "$env.WORKSPACE/build/workspace" - def resultFile = "$env.WORKSPACE/$resultFileRelative" - def configurationRoot = new File(env.WORKSPACE, rootDir).getAbsolutePath() + def resultFile = "$env.WORKSPACE/$RESULT_FILE" - steps.createDir(workspaceDir) steps.createDir(new File(resultFile).getParent()) - Logger.println("Конвертация исходников из формата конфигуратора в формат EDT") - - def ringCommand = "ring edt workspace import --configuration-files '$configurationRoot' --project-name $projectName --workspace-location '$workspaceDir'" - - def ringOpts = ['_JAVA_OPTS="-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru"'] - steps.withEnv(ringOpts) { - steps.cmd(ringCommand) - } - Logger.println("Выполнение валидации EDT") - ringCommand = "ring edt workspace validate --workspace-location '$workspaceDir' --file '$resultFile' --project-name-list $projectName" + def ringCommand = "ring edt workspace validate --workspace-location '$EdtTransform.WORKSPACE' --file '$resultFile' --project-name-list $EdtTransform.PROJECT_NAME" + def ringOpts = ['RING_OPTIONS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru'] steps.withEnv(ringOpts) { steps.cmd(ringCommand) } - steps.archiveArtifacts(resultFileRelative) - steps.stash('edt-validate', resultFileRelative) + steps.archiveArtifacts(RESULT_FILE) + steps.stash(RESULT_STASH, RESULT_FILE) } } diff --git a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy index 79cdd30a..a0e3f040 100644 --- a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy +++ b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy @@ -7,12 +7,13 @@ import ru.pulsar.jenkins.library.utils.Logger class ResultsTransformer implements Serializable { + public static final String RESULT_STASH = 'edt-generic-issue' + public static final String RESULT_FILE = 'build/out/edt-generic-issue.json' + private final JobConfiguration config; - private final String rootDir - ResultsTransformer(JobConfiguration config, String rootDir = 'src/cf') { + ResultsTransformer(JobConfiguration config) { this.config = config - this.rootDir = rootDir } def run() { @@ -32,17 +33,19 @@ class ResultsTransformer implements Serializable { return } - steps.unstash('edt-validate') + steps.unstash(EdtTransform.WORKSPACE_ZIP_STASH) + steps.unzip(EdtTransform.WORKSPACE_ZIP, EdtTransform.WORKSPACE) + + steps.unstash(EdtValidate.RESULT_STASH) Logger.println("Конвертация результата EDT в Generic Issue") - def genericIssueRelative = "build/out/edt-generic-issue.json" - def edtValidateFile = "$env.WORKSPACE/build/out/edt-validate.out" - def genericIssueFile = "$env.WORKSPACE/$genericIssueRelative" + def edtValidateFile = "$env.WORKSPACE/$EdtValidate.RESULT_FILE" + def genericIssueFile = "$env.WORKSPACE/$RESULT_FILE" - steps.cmd("stebi convert $edtValidateFile $genericIssueFile $rootDir") + steps.cmd("stebi convert $edtValidateFile $genericIssueFile $EdtTransform.WORKSPACE") - steps.archiveArtifacts(genericIssueRelative) - steps.stash('edt-generic-issue', genericIssueRelative) + steps.archiveArtifacts(RESULT_FILE) + steps.stash(RESULT_STASH, RESULT_FILE) } } diff --git a/vars/edtTransform.groovy b/vars/edtTransform.groovy new file mode 100644 index 00000000..ce1b8f51 --- /dev/null +++ b/vars/edtTransform.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.EdtTransform + +def call(JobConfiguration config, String rootDir = 'src/cf') { + ContextRegistry.registerDefaultContext(this) + + def edtTransform = new EdtTransform(config, rootDir) + edtTransform.run() +} diff --git a/vars/pipeline1C.groovy b/vars/pipeline1C.groovy index df6cdfde..f5d69b6e 100644 --- a/vars/pipeline1C.groovy +++ b/vars/pipeline1C.groovy @@ -35,13 +35,13 @@ void call() { } } - stage('1C') { - agent { - label agent1C - } + stage('Подготовка') { + parallel { + stage('Подготовка 1C базы') { + agent { + label agent1C + } - stages { - stage('Подготовка базы') { steps { printLocation() @@ -56,39 +56,54 @@ void call() { } } - stage('Проверка качества') { - parallel { - stage('EDT контроль') { - agent { - label 'edt' - } - steps { - edtValidate config - } - } - - stage('Синтаксический контроль') { - steps { - syntaxCheck config - } - } - - stage('Дымовые тесты') { - steps { - smoke config - } - } + stage('Трансформация в формат EDT') { + agent { + label 'edt' + } + steps { + edtTransform config } } + } + } - stage('Трансформация результатов') { + stage('Проверка качества') { + parallel { + stage('EDT контроль') { agent { - label 'oscript' + label 'edt' } steps { - transform config + edtValidate config } } + + stage('Синтаксический контроль') { + agent { + label agent1C + } + steps { + syntaxCheck config + } + } + + stage('Дымовые тесты') { + agent { + label agent1C + } + steps { + smoke config + } + } + } + } + + stage('Трансформация результатов') { + agent { + label 'oscript' + } + steps { + transform config } } From c489cb12ba283e3d77eeb3f0ed04561e9b0effbc Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 13:35:24 +0300 Subject: [PATCH 08/25] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6?= =?UTF-8?q?=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D1=83=D0=B4=D0=B0=D0=BB=D1=8F?= =?UTF-8?q?=D1=82=D1=8C=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0?= =?UTF-8?q?=D1=82=D1=8B=20edt=20=D0=B4=D0=BB=D1=8F=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=D0=BE=D0=B2=20=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4?= =?UTF-8?q?=D0=B5=D1=80=D0=B6=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/globalConfiguration.json | 4 +++ resources/schema.json | 15 ++++++++++ .../configuration/ConfigurationReader.groovy | 3 +- .../configuration/JobConfiguration.groovy | 5 ++++ .../ResultsTransformOptions.groovy | 28 +++++++++++++++++++ .../library/steps/ResultsTransformer.groovy | 5 ++++ .../ConfigurationReaderTest.java | 2 ++ test/unit/resources/jobConfiguration.json | 3 ++ 8 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/ru/pulsar/jenkins/library/configuration/ResultsTransformOptions.groovy diff --git a/resources/globalConfiguration.json b/resources/globalConfiguration.json index 1b561f3a..4e91adbf 100644 --- a/resources/globalConfiguration.json +++ b/resources/globalConfiguration.json @@ -31,5 +31,9 @@ "-CheckUseSynchronousCalls", "-DistributiveModules" ] + }, + "resultsTransform": { + "removeSupport": false, + "supportLevel": 0 } } diff --git a/resources/schema.json b/resources/schema.json index 89d06d2c..7af8c6c4 100644 --- a/resources/schema.json +++ b/resources/schema.json @@ -84,6 +84,21 @@ } } } + }, + "resultsTransform" : { + "type" : "object", + "id" : "urn:jsonschema:ru:pulsar:jenkins:library:configuration:ResultsTransformOptions", + "description" : "Настройки трансформации результатов анализа", + "properties" : { + "removeSupport" : { + "type" : "boolean", + "description" : "Фильтровать замечания по уровню поддержки модуля" + }, + "supportLevel" : { + "type" : "integer", + "description" : "Настройка фильтрации замечаний по уровню поддержки.\n 0 - удалить файлы на замке;\n 1 - удалить файлы на замке и на поддержке;\n 2 - удалить файлы на замке, на поддержке и снятые с поддержки.\n " + } + } } } } \ No newline at end of file diff --git a/src/ru/pulsar/jenkins/library/configuration/ConfigurationReader.groovy b/src/ru/pulsar/jenkins/library/configuration/ConfigurationReader.groovy index 159991a0..d17ddf58 100644 --- a/src/ru/pulsar/jenkins/library/configuration/ConfigurationReader.groovy +++ b/src/ru/pulsar/jenkins/library/configuration/ConfigurationReader.groovy @@ -42,7 +42,8 @@ class ConfigurationReader implements Serializable { "secrets", "stageFlags", "sonarQubeOptions", - "syntaxCheckOptions" + "syntaxCheckOptions", + "resultsTransformOptions" ).toSet() mergeObjects(baseConfiguration, configurationToMerge, nonMergeableSettings) diff --git a/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy b/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy index 9fbad207..7b228cf0 100644 --- a/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy +++ b/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy @@ -25,6 +25,10 @@ class JobConfiguration implements Serializable { @JsonPropertyDescription("Настройки синтаксического контроля") SyntaxCheckOptions syntaxCheckOptions; + @JsonProperty("resultsTransform") + @JsonPropertyDescription("Настройки трансформации результатов анализа") + ResultsTransformOptions resultsTransformOptions; + @Override @NonCPS String toString() { @@ -34,6 +38,7 @@ class JobConfiguration implements Serializable { ", secrets=" + secrets + ", sonarQubeOptions=" + sonarQubeOptions + ", syntaxCheckOptions=" + syntaxCheckOptions + + ", resultsTransformOptions=" + resultsTransformOptions + '}'; } } \ No newline at end of file diff --git a/src/ru/pulsar/jenkins/library/configuration/ResultsTransformOptions.groovy b/src/ru/pulsar/jenkins/library/configuration/ResultsTransformOptions.groovy new file mode 100644 index 00000000..c159fd27 --- /dev/null +++ b/src/ru/pulsar/jenkins/library/configuration/ResultsTransformOptions.groovy @@ -0,0 +1,28 @@ +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 ResultsTransformOptions implements Serializable { + + @JsonPropertyDescription("Фильтровать замечания по уровню поддержки модуля") + boolean removeSupport + + @JsonPropertyDescription("""Настройка фильтрации замечаний по уровню поддержки. + 0 - удалить файлы на замке; + 1 - удалить файлы на замке и на поддержке; + 2 - удалить файлы на замке, на поддержке и снятые с поддержки. + """) + int supportLevel + + @Override + @NonCPS + String toString() { + return "ResultsTransformOptions{" + + "removeSupport=" + removeSupport + + ", supportLevel=" + supportLevel + + '}'; + } +} diff --git a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy index a0e3f040..767bb0bb 100644 --- a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy +++ b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy @@ -45,6 +45,11 @@ class ResultsTransformer implements Serializable { steps.cmd("stebi convert $edtValidateFile $genericIssueFile $EdtTransform.WORKSPACE") + if (config.resultsTransformOptions.removeSupport) { + def supportLevel = config.resultsTransformOptions.supportLevel + steps.cmd("stebi transform --remove_support $supportLevel --src $EdtTransform.WORKSPACE $genericIssueFile") + } + steps.archiveArtifacts(RESULT_FILE) steps.stash(RESULT_STASH, RESULT_FILE) } diff --git a/test/unit/groovy/ru/pulsar/jenkins/library/configuration/ConfigurationReaderTest.java b/test/unit/groovy/ru/pulsar/jenkins/library/configuration/ConfigurationReaderTest.java index b15a3a7b..01e4edc7 100644 --- a/test/unit/groovy/ru/pulsar/jenkins/library/configuration/ConfigurationReaderTest.java +++ b/test/unit/groovy/ru/pulsar/jenkins/library/configuration/ConfigurationReaderTest.java @@ -37,6 +37,8 @@ void testCreateJobConfigurationObject() throws IOException { .hasFieldOrPropertyWithValue("storagePath", "UNKNOWN_ID") ; assertThat(jobConfiguration.getSyntaxCheckOptions().getCheckModes()).hasSize(1); + assertThat(jobConfiguration.getResultsTransformOptions().isRemoveSupport()).isTrue(); + assertThat(jobConfiguration.getResultsTransformOptions().getSupportLevel()).isEqualTo(0); } } \ No newline at end of file diff --git a/test/unit/resources/jobConfiguration.json b/test/unit/resources/jobConfiguration.json index 28070989..2cd66f29 100644 --- a/test/unit/resources/jobConfiguration.json +++ b/test/unit/resources/jobConfiguration.json @@ -8,5 +8,8 @@ }, "syntaxCheck": { "checkModes": ["-ThinClient"] + }, + "resultsTransform": { + "removeSupport": true } } \ No newline at end of file From 7c1ef7c2cce0c20195ea66e94c79a6aed5898a2c Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 13:51:57 +0300 Subject: [PATCH 09/25] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0?= =?UTF-8?q?=20=D1=80=D0=B0=D0=B7=D0=B0=D1=80=D1=85=D0=B8=D0=B2=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index 6d91c15c..78065afd 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -29,7 +29,7 @@ class EdtValidate implements Serializable { } steps.unstash(EdtTransform.WORKSPACE_ZIP_STASH) - steps.unzip(EdtTransform.WORKSPACE_ZIP, EdtTransform.WORKSPACE) + steps.unzip(EdtTransform.WORKSPACE, EdtTransform.WORKSPACE_ZIP) def env = steps.env(); From 9a8b0a182d0eaea4d2ac85b6b60726d9ff5b70cc Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 13:52:07 +0300 Subject: [PATCH 10/25] =?UTF-8?q?=D0=A3=D1=81=D0=BB=D0=BE=D0=B2=D0=BD?= =?UTF-8?q?=D0=BE=D0=B5=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20stages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/configuration/StageFlags.groovy | 4 +++ vars/pipeline1C.groovy | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/ru/pulsar/jenkins/library/configuration/StageFlags.groovy b/src/ru/pulsar/jenkins/library/configuration/StageFlags.groovy index 4aef055a..c73a1586 100644 --- a/src/ru/pulsar/jenkins/library/configuration/StageFlags.groovy +++ b/src/ru/pulsar/jenkins/library/configuration/StageFlags.groovy @@ -28,4 +28,8 @@ class StageFlags implements Serializable { ", smoke=" + smoke + '}'; } + + boolean needInfobase() { + return smoke || syntaxCheck + } } diff --git a/vars/pipeline1C.groovy b/vars/pipeline1C.groovy index f5d69b6e..d07006f9 100644 --- a/vars/pipeline1C.groovy +++ b/vars/pipeline1C.groovy @@ -41,6 +41,10 @@ void call() { agent { label agent1C } + when { + beforeAgent true + expression { config.stageFlags.needInfobase() } + } steps { printLocation() @@ -60,6 +64,10 @@ void call() { agent { label 'edt' } + when { + beforeAgent true + expression { config.stageFlags.edtValidate } + } steps { edtTransform config } @@ -73,6 +81,10 @@ void call() { agent { label 'edt' } + when { + beforeAgent true + expression { config.stageFlags.edtValidate } + } steps { edtValidate config } @@ -82,6 +94,10 @@ void call() { agent { label agent1C } + when { + beforeAgent true + expression { config.stageFlags.syntaxCheck } + } steps { syntaxCheck config } @@ -91,6 +107,10 @@ void call() { agent { label agent1C } + when { + beforeAgent true + expression { config.stageFlags.smoke } + } steps { smoke config } @@ -102,6 +122,10 @@ void call() { agent { label 'oscript' } + when { + beforeAgent true + expression { config.stageFlags.edtValidate } + } steps { transform config } @@ -111,6 +135,10 @@ void call() { agent { label 'sonar' } + when { + beforeAgent true + expression { config.stageFlags.sonarqube } + } steps { sonarScanner config } From 418a8bf8199dc40cb3eb1896afd385dcc08080a5 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 13:55:57 +0300 Subject: [PATCH 11/25] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B7=D0=B0=D0=BF=D1=83=D1=81?= =?UTF-8?q?=D0=BA=D0=B0=20edt=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20unstash?= =?UTF-8?q?=20workspace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index 78065afd..a41ea1bb 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -34,12 +34,13 @@ class EdtValidate implements Serializable { def env = steps.env(); def resultFile = "$env.WORKSPACE/$RESULT_FILE" + def workspaceLocation = "$env.WORKSPACE/$EdtTransform.WORKSPACE" steps.createDir(new File(resultFile).getParent()) Logger.println("Выполнение валидации EDT") - def ringCommand = "ring edt workspace validate --workspace-location '$EdtTransform.WORKSPACE' --file '$resultFile' --project-name-list $EdtTransform.PROJECT_NAME" + def ringCommand = "ring edt workspace validate --workspace-location '$workspaceLocation' --file '$resultFile' --project-name-list $EdtTransform.PROJECT_NAME" def ringOpts = ['RING_OPTIONS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru'] steps.withEnv(ringOpts) { From 515a91dcc1afccb566fcfc6a2bad93f2423559cc Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 13:59:42 +0300 Subject: [PATCH 12/25] =?UTF-8?q?=D0=A2=D0=B8=D1=85=D0=B8=D0=B9=20unzip=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=83=D0=BC=D0=BE=D0=BB=D1=87=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/IStepExecutor.groovy | 2 ++ src/ru/pulsar/jenkins/library/StepExecutor.groovy | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy index 4eac192a..16981f97 100644 --- a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy @@ -41,4 +41,6 @@ interface IStepExecutor { def zip(String dir, String zipFile, String glob) def unzip(String dir, String zipFile) + + def unzip(String dir, String zipFile, quiet) } \ 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 e78ad47d..59baa3f8 100644 --- a/src/ru/pulsar/jenkins/library/StepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/StepExecutor.groovy @@ -95,7 +95,7 @@ class StepExecutor implements IStepExecutor { } @Override - def unzip(String dir, String zipFile) { - steps.unzip dir: dir, zipFile: zipFile + def unzip(String dir, String zipFile, quiet = true) { + steps.unzip dir: dir, zipFile: zipFile, quiet: quiet } } From 540b90fceb16363175ea906f8b037804020320bb Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 17:04:49 +0300 Subject: [PATCH 13/25] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=B2=D1=80=D0=B0?= =?UTF-8?q?=D1=82=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B8=D0=B7=20=D1=88=D0=B0=D0=B3=D0=B0=20cmd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jenkins/library/IStepExecutor.groovy | 4 ++-- .../jenkins/library/StepExecutor.groovy | 4 ++-- test/integration/groovy/cmdTest.groovy | 24 +++++++++++++++++++ vars/cmd.groovy | 2 +- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy index 16981f97..e6a43221 100644 --- a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy @@ -16,9 +16,9 @@ interface IStepExecutor { void echo(message) - void cmd(String script, boolean returnStatus) + int cmd(String script, boolean returnStatus) - void cmd(String script) + int cmd(String script) void tool(String toolName) diff --git a/src/ru/pulsar/jenkins/library/StepExecutor.groovy b/src/ru/pulsar/jenkins/library/StepExecutor.groovy index 59baa3f8..4b66f22a 100644 --- a/src/ru/pulsar/jenkins/library/StepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/StepExecutor.groovy @@ -41,8 +41,8 @@ class StepExecutor implements IStepExecutor { } @Override - void cmd(String script, boolean returnStatus = false) { - steps.cmd(script, returnStatus) + int cmd(String script, boolean returnStatus = false) { + return steps.cmd(script, returnStatus) } @Override diff --git a/test/integration/groovy/cmdTest.groovy b/test/integration/groovy/cmdTest.groovy index 0d3283bf..f9ddc71d 100644 --- a/test/integration/groovy/cmdTest.groovy +++ b/test/integration/groovy/cmdTest.groovy @@ -35,4 +35,28 @@ class cmdTest { rule.assertLogContains('helloWorld', rule.buildAndAssertSuccess(workflowJob)) } + + @Test + void "cmd should return status"() { + def pipeline = ''' + pipeline { + agent any + stages { + stage('test') { + steps { + script { + def status = cmd("false", true) + echo "status = $status" + } + } + } + } + } + '''.stripIndent() + final CpsFlowDefinition flow = new CpsFlowDefinition(pipeline, true) + final WorkflowJob workflowJob = rule.createProject(WorkflowJob, 'project') + workflowJob.definition = flow + + rule.assertLogContains('status = 1', rule.buildAndAssertSuccess(workflowJob)) + } } \ No newline at end of file diff --git a/vars/cmd.groovy b/vars/cmd.groovy index c9241191..b5ad0568 100644 --- a/vars/cmd.groovy +++ b/vars/cmd.groovy @@ -5,5 +5,5 @@ int call(String script, boolean returnStatus = false) { ContextRegistry.registerDefaultContext(this) def cmd = new Cmd(script, returnStatus) - cmd.run() + return cmd.run() } From a584b5ab368161e31affee7c8b4c82603285f971 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 17:05:03 +0300 Subject: [PATCH 14/25] =?UTF-8?q?=D0=A1=D0=BE=D1=85=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B0=20edt=20val?= =?UTF-8?q?idate=20=D0=B2=20=D0=B0=D1=80=D1=82=D0=B5=D1=84=D0=B0=D0=BA?= =?UTF-8?q?=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/IStepExecutor.groovy | 4 +++- src/ru/pulsar/jenkins/library/StepExecutor.groovy | 5 +++++ src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy | 6 ++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy index e6a43221..8942a1cf 100644 --- a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy @@ -41,6 +41,8 @@ interface IStepExecutor { def zip(String dir, String zipFile, String glob) def unzip(String dir, String zipFile) - + def unzip(String dir, String zipFile, quiet) + + def catchError(Closure body) } \ 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 4b66f22a..2b425a53 100644 --- a/src/ru/pulsar/jenkins/library/StepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/StepExecutor.groovy @@ -98,4 +98,9 @@ class StepExecutor implements IStepExecutor { def unzip(String dir, String zipFile, quiet = true) { steps.unzip dir: dir, zipFile: zipFile, quiet: quiet } + + @Override + def catchError(Closure body) { + steps.catchError body + } } diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index a41ea1bb..eeeba493 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -44,9 +44,11 @@ class EdtValidate implements Serializable { def ringOpts = ['RING_OPTIONS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru'] steps.withEnv(ringOpts) { - steps.cmd(ringCommand) + steps.catchError { + steps.cmd(ringCommand) + } } - + steps.archiveArtifacts("$EdtTransform.WORKSPACE/.metadata/.log") steps.archiveArtifacts(RESULT_FILE) steps.stash(RESULT_STASH, RESULT_FILE) } From 9eb9cdd81f42c6399ded1e2ae08728d47b68405c Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 17:19:16 +0300 Subject: [PATCH 15/25] =?UTF-8?q?=D0=92=D0=B5=D1=81=D1=8C=20=D0=B2=D0=BE?= =?UTF-8?q?=D1=80=D0=BA=D1=81=D0=BF=D0=B5=D0=B9=D1=81=20=D0=B5=D0=B4=D1=82?= =?UTF-8?q?=20=D0=B2=20=D0=B0=D1=80=D1=82=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Отладка --- src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index eeeba493..a3a65d3d 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -48,6 +48,8 @@ class EdtValidate implements Serializable { steps.cmd(ringCommand) } } + steps.zip(EdtTransform.WORKSPACE, "temp.workspace.zip") + steps.archiveArtifacts("temp.workspace.zip") steps.archiveArtifacts("$EdtTransform.WORKSPACE/.metadata/.log") steps.archiveArtifacts(RESULT_FILE) steps.stash(RESULT_STASH, RESULT_FILE) From 27fae3607b32cb240e099a26d34833a7cf17c063 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 17:41:35 +0300 Subject: [PATCH 16/25] RING_OPTS --- src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index a3a65d3d..23625ad7 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -41,8 +41,7 @@ class EdtValidate implements Serializable { Logger.println("Выполнение валидации EDT") def ringCommand = "ring edt workspace validate --workspace-location '$workspaceLocation' --file '$resultFile' --project-name-list $EdtTransform.PROJECT_NAME" - def ringOpts = ['RING_OPTIONS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru'] - + def ringOpts = ['RING_OPTS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru'] steps.withEnv(ringOpts) { steps.catchError { steps.cmd(ringCommand) From 8e81f02ebbe6c021807b81f623560ed717aaacab Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 19:25:23 +0300 Subject: [PATCH 17/25] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BE=D0=B3=D1=80=D0=B0=D0=BD=D0=B8=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20xmx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index 23625ad7..0fc49b2c 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -41,7 +41,7 @@ class EdtValidate implements Serializable { Logger.println("Выполнение валидации EDT") def ringCommand = "ring edt workspace validate --workspace-location '$workspaceLocation' --file '$resultFile' --project-name-list $EdtTransform.PROJECT_NAME" - def ringOpts = ['RING_OPTS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru'] + def ringOpts = ['RING_OPTS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru -Xmx2g'] steps.withEnv(ringOpts) { steps.catchError { steps.cmd(ringCommand) From fa117a298926e8ad11cbd5802c6ffb961ada1bb7 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 20:54:49 +0300 Subject: [PATCH 18/25] =?UTF-8?q?unzip=20=D0=B2=20=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE=D0=BC=20=D0=BF=D0=BE=D1=80=D1=8F?= =?UTF-8?q?=D0=B4=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy index 767bb0bb..c612237c 100644 --- a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy +++ b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy @@ -34,7 +34,7 @@ class ResultsTransformer implements Serializable { } steps.unstash(EdtTransform.WORKSPACE_ZIP_STASH) - steps.unzip(EdtTransform.WORKSPACE_ZIP, EdtTransform.WORKSPACE) + steps.unzip(EdtTransform.WORKSPACE, EdtTransform.WORKSPACE_ZIP) steps.unstash(EdtValidate.RESULT_STASH) From 26bbd5af637ccf09a183c6c080a2e96d408e598f Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 19:57:37 +0000 Subject: [PATCH 19/25] 3g --- src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index 0fc49b2c..400e142e 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -41,7 +41,7 @@ class EdtValidate implements Serializable { Logger.println("Выполнение валидации EDT") def ringCommand = "ring edt workspace validate --workspace-location '$workspaceLocation' --file '$resultFile' --project-name-list $EdtTransform.PROJECT_NAME" - def ringOpts = ['RING_OPTS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru -Xmx2g'] + def ringOpts = ['RING_OPTS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru -Xmx3g'] steps.withEnv(ringOpts) { steps.catchError { steps.cmd(ringCommand) From e7e2fddd0b1290d6b8d4ed5a4456cd10cf989935 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 20:28:11 +0000 Subject: [PATCH 20/25] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B0=D1=80=D1=85=D0=B8=D0=B2=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B2?= =?UTF-8?q?=D0=BE=D1=80=D0=BA=D1=81=D0=BF=D0=B5=D0=B9=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index 400e142e..19737285 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -47,8 +47,6 @@ class EdtValidate implements Serializable { steps.cmd(ringCommand) } } - steps.zip(EdtTransform.WORKSPACE, "temp.workspace.zip") - steps.archiveArtifacts("temp.workspace.zip") steps.archiveArtifacts("$EdtTransform.WORKSPACE/.metadata/.log") steps.archiveArtifacts(RESULT_FILE) steps.stash(RESULT_STASH, RESULT_FILE) From 8162590a09588a6f6cbbf0c7046030ff819fd7a4 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 20:28:36 +0000 Subject: [PATCH 21/25] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B0=20xmx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index 19737285..6ea79f0b 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -41,7 +41,7 @@ class EdtValidate implements Serializable { Logger.println("Выполнение валидации EDT") def ringCommand = "ring edt workspace validate --workspace-location '$workspaceLocation' --file '$resultFile' --project-name-list $EdtTransform.PROJECT_NAME" - def ringOpts = ['RING_OPTS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru -Xmx3g'] + def ringOpts = ['RING_OPTS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru'] steps.withEnv(ringOpts) { steps.catchError { steps.cmd(ringCommand) From 5bf54fbe0de791ed0dc8a5e86a0f4c0685258a25 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Wed, 29 Apr 2020 23:44:59 +0300 Subject: [PATCH 22/25] =?UTF-8?q?=D0=A3=D0=BA=D0=B0=D0=B7=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D1=83=D1=82=D0=B8=20=D0=BA=20src?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pulsar/jenkins/library/steps/ResultsTransformer.groovy | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy index c612237c..b5c8ebe1 100644 --- a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy +++ b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy @@ -42,12 +42,13 @@ class ResultsTransformer implements Serializable { def edtValidateFile = "$env.WORKSPACE/$EdtValidate.RESULT_FILE" def genericIssueFile = "$env.WORKSPACE/$RESULT_FILE" + def srcDir = "$EdtTransform.WORKSPACE/$EdtTransform.PROJECT_NAME/src" - steps.cmd("stebi convert $edtValidateFile $genericIssueFile $EdtTransform.WORKSPACE") + steps.cmd("stebi convert $edtValidateFile $genericIssueFile $srcDir") if (config.resultsTransformOptions.removeSupport) { def supportLevel = config.resultsTransformOptions.supportLevel - steps.cmd("stebi transform --remove_support $supportLevel --src $EdtTransform.WORKSPACE $genericIssueFile") + steps.cmd("stebi transform --remove_support $supportLevel --src $srcDir $genericIssueFile") } steps.archiveArtifacts(RESULT_FILE) From 3b52660c29871d2de67c735af742c16e2c474dea Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Thu, 30 Apr 2020 00:05:53 +0300 Subject: [PATCH 23/25] =?UTF-8?q?=D0=97=D0=B0=D0=BF=D1=83=D1=81=D0=BA=20st?= =?UTF-8?q?ebi=20=D0=BD=D0=B0=20=D0=B8=D1=81=D1=85=D0=BE=D0=B4=D0=BD=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0=D1=85=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D1=83?= =?UTF-8?q?=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy index b5c8ebe1..9fe943b7 100644 --- a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy +++ b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy @@ -42,7 +42,7 @@ class ResultsTransformer implements Serializable { def edtValidateFile = "$env.WORKSPACE/$EdtValidate.RESULT_FILE" def genericIssueFile = "$env.WORKSPACE/$RESULT_FILE" - def srcDir = "$EdtTransform.WORKSPACE/$EdtTransform.PROJECT_NAME/src" + def srcDir = "src/cf" steps.cmd("stebi convert $edtValidateFile $genericIssueFile $srcDir") From 43224739bcafb2df4d9037815a4d4778c1a9a206 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Thu, 30 Apr 2020 17:03:11 +0300 Subject: [PATCH 24/25] =?UTF-8?q?=D0=9F=D0=B0=D1=80=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D1=80=20srcDir=20=D0=B2=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8?= =?UTF-8?q?=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/globalConfiguration.json | 1 + resources/schema.json | 4 ++++ .../library/configuration/JobConfiguration.groovy | 4 ++++ .../jenkins/library/steps/EdtTransform.groovy | 6 ++---- .../pulsar/jenkins/library/steps/EdtValidate.groovy | 4 +--- .../jenkins/library/steps/ResultsTransformer.groovy | 13 ++----------- .../jenkins/library/steps/SonarScanner.groovy | 4 ++-- vars/edtTransform.groovy | 4 ++-- vars/edtValidate.groovy | 4 ++-- vars/sonarScanner.groovy | 4 ++-- 10 files changed, 22 insertions(+), 26 deletions(-) diff --git a/resources/globalConfiguration.json b/resources/globalConfiguration.json index 4e91adbf..332119d2 100644 --- a/resources/globalConfiguration.json +++ b/resources/globalConfiguration.json @@ -1,5 +1,6 @@ { "$schema": "schema.json", + "srcDir": "src/cf", "secrets": { "storagePath": "UNKNOWN_ID", "storage": "UNKNOWN_ID" diff --git a/resources/schema.json b/resources/schema.json index 7af8c6c4..40bcd1cc 100644 --- a/resources/schema.json +++ b/resources/schema.json @@ -6,6 +6,10 @@ "type" : "string", "description" : "Версия платформы 1С:Предприятие в формате 8.3.хх.хххх." }, + "srcDir" : { + "type" : "string", + "description" : "Путь к корневому каталогу с исходниками конфигурации" + }, "secrets" : { "type" : "object", "id" : "urn:jsonschema:ru:pulsar:jenkins:library:configuration:Secrets", diff --git a/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy b/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy index 7b228cf0..3368d8e3 100644 --- a/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy +++ b/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy @@ -10,6 +10,9 @@ class JobConfiguration implements Serializable { @JsonPropertyDescription("Версия платформы 1С:Предприятие в формате 8.3.хх.хххх.") String v8version + @JsonPropertyDescription("Путь к корневому каталогу с исходниками конфигурации") + String srcDir + @JsonProperty("stages") @JsonPropertyDescription("Включение этапов сборок") StageFlags stageFlags; @@ -34,6 +37,7 @@ class JobConfiguration implements Serializable { String toString() { return "JobConfiguration{" + "v8version='" + v8version + '\'' + + ", srcDir='" + srcDir + '\'' + ", stageFlags=" + stageFlags + ", secrets=" + secrets + ", sonarQubeOptions=" + sonarQubeOptions + diff --git a/src/ru/pulsar/jenkins/library/steps/EdtTransform.groovy b/src/ru/pulsar/jenkins/library/steps/EdtTransform.groovy index a13fdb7b..4b2a065d 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtTransform.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtTransform.groovy @@ -13,11 +13,9 @@ class EdtTransform implements Serializable { public static final String WORKSPACE_ZIP_STASH = 'edt-workspace-zip' private final JobConfiguration config; - private final String rootDir - EdtTransform(JobConfiguration config, String rootDir = 'src/cf') { + EdtTransform(JobConfiguration config) { this.config = config - this.rootDir = rootDir } def run() { @@ -33,7 +31,7 @@ class EdtTransform implements Serializable { def env = steps.env(); def workspaceDir = "$env.WORKSPACE/$WORKSPACE" - def configurationRoot = new File(env.WORKSPACE, rootDir).getAbsolutePath() + def configurationRoot = new File(env.WORKSPACE, config.srcDir).getAbsolutePath() steps.createDir(workspaceDir) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index 6ea79f0b..febc0fc5 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -11,11 +11,9 @@ class EdtValidate implements Serializable { public static final String RESULT_FILE = 'build/out/edt-validate.out' private final JobConfiguration config; - private final String rootDir - EdtValidate(JobConfiguration config, String rootDir = 'src/cf') { + EdtValidate(JobConfiguration config) { this.config = config - this.rootDir = rootDir } def run() { diff --git a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy index 9fe943b7..890466b7 100644 --- a/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy +++ b/src/ru/pulsar/jenkins/library/steps/ResultsTransformer.groovy @@ -21,11 +21,6 @@ class ResultsTransformer implements Serializable { Logger.printLocation() - if (!config.stageFlags.sonarqube) { - Logger.println("No transform is needed.") - return - } - def env = steps.env(); if (!config.stageFlags.edtValidate) { @@ -33,22 +28,18 @@ class ResultsTransformer implements Serializable { return } - steps.unstash(EdtTransform.WORKSPACE_ZIP_STASH) - steps.unzip(EdtTransform.WORKSPACE, EdtTransform.WORKSPACE_ZIP) - steps.unstash(EdtValidate.RESULT_STASH) Logger.println("Конвертация результата EDT в Generic Issue") def edtValidateFile = "$env.WORKSPACE/$EdtValidate.RESULT_FILE" def genericIssueFile = "$env.WORKSPACE/$RESULT_FILE" - def srcDir = "src/cf" - steps.cmd("stebi convert $edtValidateFile $genericIssueFile $srcDir") + steps.cmd("stebi convert $edtValidateFile $genericIssueFile $config.srcDir") if (config.resultsTransformOptions.removeSupport) { def supportLevel = config.resultsTransformOptions.supportLevel - steps.cmd("stebi transform --remove_support $supportLevel --src $srcDir $genericIssueFile") + steps.cmd("stebi transform --remove_support $supportLevel --src $config.srcDir $genericIssueFile") } steps.archiveArtifacts(RESULT_FILE) diff --git a/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy b/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy index e4bc3502..a75f6ecd 100644 --- a/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy +++ b/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy @@ -11,9 +11,9 @@ class SonarScanner implements Serializable { private final JobConfiguration config; private final String rootFile - SonarScanner(JobConfiguration config, String rootFile = 'src/cf/Configuration.xml') { + SonarScanner(JobConfiguration config) { this.config = config - this.rootFile = rootFile + this.rootFile = "$config.srcDir/Configuration.xml" } def run() { diff --git a/vars/edtTransform.groovy b/vars/edtTransform.groovy index ce1b8f51..de901e53 100644 --- a/vars/edtTransform.groovy +++ b/vars/edtTransform.groovy @@ -2,9 +2,9 @@ import ru.pulsar.jenkins.library.configuration.JobConfiguration import ru.pulsar.jenkins.library.ioc.ContextRegistry import ru.pulsar.jenkins.library.steps.EdtTransform -def call(JobConfiguration config, String rootDir = 'src/cf') { +def call(JobConfiguration config) { ContextRegistry.registerDefaultContext(this) - def edtTransform = new EdtTransform(config, rootDir) + def edtTransform = new EdtTransform(config) edtTransform.run() } diff --git a/vars/edtValidate.groovy b/vars/edtValidate.groovy index 679acc8e..df2d26cc 100644 --- a/vars/edtValidate.groovy +++ b/vars/edtValidate.groovy @@ -2,9 +2,9 @@ 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') { +def call(JobConfiguration config) { ContextRegistry.registerDefaultContext(this) - def edtValidate = new EdtValidate(config, rootDir) + def edtValidate = new EdtValidate(config) edtValidate.run() } diff --git a/vars/sonarScanner.groovy b/vars/sonarScanner.groovy index 920799ac..e37fafd1 100644 --- a/vars/sonarScanner.groovy +++ b/vars/sonarScanner.groovy @@ -2,9 +2,9 @@ import ru.pulsar.jenkins.library.configuration.JobConfiguration import ru.pulsar.jenkins.library.ioc.ContextRegistry import ru.pulsar.jenkins.library.steps.SonarScanner -def call(JobConfiguration config, String rootFile = 'src/cf/Configuration.xml') { +def call(JobConfiguration config) { ContextRegistry.registerDefaultContext(this) - def sonarScanner = new SonarScanner(config, rootFile) + def sonarScanner = new SonarScanner(config) sonarScanner.run() } From c4ac74be51ab9f1d8b93a4fd965620db1fddf2be Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Thu, 30 Apr 2020 17:25:06 +0300 Subject: [PATCH 25/25] =?UTF-8?q?=D0=A0=D0=B0=D1=81=D1=88=D0=B8=D1=80?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fc0d9c81..b81bb4e7 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Создание библиотеки (или плагина) для Jenkins, позволяющей: * максимально упростить написание Jenkinsfile для процесса CI в условиях платформы 1С:Предприятие 8 -* иметь схожий и контроллируемый пайплайн для всех проектов +* иметь схожий и контролируемый пайплайн для всех проектов * дать пользователю в руки простой декларативный конфигурационный файл, вместо требования описывать всю сложную логику по работе с 1С ## Общие положения @@ -21,11 +21,21 @@ 1. Для шага подготовки требуется любой агент с меткой `agent`. 1. Для запуска шага анализа SonarQube требуется агент с меткой `sonar`. +1. Для запуска шага валидации EDT требуется агент с меткой `edt` (для собственно валидации) и агент с меткой `oscript` (для трансформации результатов с помощью библиотеки [stebi](https://github.com/Stepa86/stebi)). 1. Для запуска шагов, работающих с 1С (подготовка, синтаксический контроль и т.д.) требуется агент с меткой, совпадающей со значением в поле `v8version` файла конфигурации. 1. В качестве ИБ используется файловая база, создаваемая в `./build/ib`, без данных авторизации. Переопределение "в следующих сериях". 1. Stage "Дымовые тесты" пока пустой. 1. Запуск `vrunner` на текущий момент происходит из локального каталога `oscript_modules`. Предполагается наличие в корне репозитория файла `packagedef`, в котором бы была указана зависимость от `vanessa-runner` +## Возможности + +1. Все шаги можно запустить на базе docker-образов из форка репозитория onec-docker. См. [памятку по слоям и последовательности сборки](https://github.com/firstBitSemenovskaya/onec-docker/blob/feature/first-bit/Layers.md) +1. Трансформация кода из формата конфигуратора в формат EDT (только если включен шаг `edtValidate`). +1. Подготовка информационной базы по версии из хранилища конфигурации. +1. Запуск синтаксического контроля средствами конфигуратора и сохранение результатов в виде отчета jUnit. +1. Запуск валидации проекта средствами EDT и конвертация отчета в формате generic issues. +1. Запуск статического анализа для SonarQube + ## Подключение Инструкция по подключению библиотеки: https://jenkins.io/doc/book/pipeline/shared-libraries/#using-libraries @@ -48,7 +58,7 @@ pipeline1C() > Да, вот и весь пайплайн. Конфигурирование через json. -## Конфигуирование +## Конфигурирование По умолчанию применяется [файл конфигурации из ресурсов библиотеки](resources/globalConfiguration.json) @@ -57,11 +67,12 @@ pipeline1C() Пример переопределения: * указывается точная версия платформы (и соответственно метка агента, см. ограничения) -* идентификаторы credentials для пути к хранилищу и к паре логин/пароль для авторизации в хранилище -* включаются шаги запуска статического анализа и синтаксического контроля +* идентификаторы credentials для пути к хранилищу и к паре логин/пароль для авторизации в хранилище (необходимы, если применяются шаги, работающие с информационной базой) +* включаются шаги запуска статического анализа SonarQube, валидации средствами EDT и синтаксического контроля ```json { + "$schema": "https://raw.githubusercontent.com/firstBitSemenovskaya/jenkins-lib/master/resources/schema.json", "v8version": "8.3.14.1976", "secrets": { "storagePath": "f7b21c02-711a-4883-81c5-d429454e3f8b", @@ -69,6 +80,7 @@ pipeline1C() }, "stages": { "sonarqube": true, + "edtValidation": true, "syntaxCheck": true } }