From 7312b7e75a41f18756eddef96b78959e7001a6d5 Mon Sep 17 00:00:00 2001 From: ivanovEV Date: Fri, 8 Apr 2022 15:05:14 +0300 Subject: [PATCH 01/10] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=20use?= =?UTF-8?q?BranchPlugin?= 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/configuration/SonarQubeOptions.groovy | 4 ++++ src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy | 6 +++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/resources/globalConfiguration.json b/resources/globalConfiguration.json index 7ed9f03..b68db16 100644 --- a/resources/globalConfiguration.json +++ b/resources/globalConfiguration.json @@ -43,7 +43,8 @@ "sonarQubeInstallation": "", "useSonarScannerFromPath": true, "sonarScannerToolName": "sonar-scanner", - "infoBaseUpdateModuleName" : "" + "infoBaseUpdateModuleName" : "", + "useBranchPlugin" : true }, "syntaxCheck": { "groupErrorsByMetadata": true, diff --git a/resources/schema.json b/resources/schema.json index 5d2c076..f94f575 100644 --- a/resources/schema.json +++ b/resources/schema.json @@ -173,6 +173,10 @@ "infoBaseUpdateModuleName" : { "type" : "string", "description" : "Имя общего модуля (например, ОбновлениеИнформационнойБазыXXX), в котором указана версия библиотеки.\n Версия должна задаваться в виде присвоения `Описание.Версия = \"ваш номер версии\";`\n " + }, + "useBranchPlugin" : { + "type" : "boolean", + "description" : "Используется ли Branch-plugin в SonarQube" } } }, diff --git a/src/ru/pulsar/jenkins/library/configuration/SonarQubeOptions.groovy b/src/ru/pulsar/jenkins/library/configuration/SonarQubeOptions.groovy index dad4964..7c2c3a5 100644 --- a/src/ru/pulsar/jenkins/library/configuration/SonarQubeOptions.groovy +++ b/src/ru/pulsar/jenkins/library/configuration/SonarQubeOptions.groovy @@ -25,6 +25,9 @@ class SonarQubeOptions implements Serializable { """) String infoBaseUpdateModuleName + @JsonPropertyDescription("Используется ли Branch-plugin в SonarQube") + Boolean useBranchPlugin + @Override @NonCPS String toString() { @@ -33,6 +36,7 @@ class SonarQubeOptions implements Serializable { ", sonarScannerToolName='" + sonarScannerToolName + '\'' + ", sonarQubeInstallation='" + sonarQubeInstallation + '\'' + ", infoBaseUpdateModuleName='" + infoBaseUpdateModuleName + '\'' + + ", useBranchPlugin='" + useBranchPlugin + '\'' + '}'; } } diff --git a/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy b/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy index 022e187..b1a4348 100644 --- a/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy +++ b/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy @@ -36,7 +36,11 @@ class SonarScanner implements Serializable { sonarScannerBinary = "$scannerHome/bin/sonar-scanner" } - String sonarCommand = "$sonarScannerBinary -Dsonar.branch.name=$env.BRANCH_NAME" + String sonarCommand = "$sonarScannerBinary" + + if (config.sonarQubeOptions.useBranchPlugin) { + sonarCommand += " -Dsonar.branch.name=$env.BRANCH_NAME" + } String projectVersion = computeProjectVersion() if (projectVersion) { From 72b9510fecacfdca6b2470826fb17788450b75a6 Mon Sep 17 00:00:00 2001 From: ivanmolodec Date: Fri, 13 May 2022 22:29:07 +0300 Subject: [PATCH 02/10] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80?= =?UTF-8?q?=20edtVersion=20=D0=B2=20=D1=81=D1=85=D0=B5=D0=BC=D1=83.=20?= =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80?= =?UTF-8?q?=D0=B0=20=D0=B2=20=D1=88=D0=B0=D0=B3=D0=B5=20DesignerToEdtForma?= =?UTF-8?q?tTransformation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/globalConfiguration.json | 1 + resources/schema.json | 4 ++++ .../jenkins/library/configuration/JobConfiguration.groovy | 4 ++++ .../library/steps/DesignerToEdtFormatTransformation.groovy | 7 ++++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/resources/globalConfiguration.json b/resources/globalConfiguration.json index b68db16..8de4eee 100644 --- a/resources/globalConfiguration.json +++ b/resources/globalConfiguration.json @@ -1,6 +1,7 @@ { "$schema": "schema.json", "v8version": "8.3", + "edtVersion": "", "srcDir": "src/cf", "sourceFormat": "designer", "defaultBranch": "main", diff --git a/resources/schema.json b/resources/schema.json index f94f575..f796d0d 100644 --- a/resources/schema.json +++ b/resources/schema.json @@ -6,6 +6,10 @@ "type" : "string", "description" : "Версия платформы 1С:Предприятие в формате 8.3.хх.хххх." }, + "edtVersion" : { + "type" : "string", + "description" : "Версия модуля 1C:Enterprise Development Tools формате xxxx.x.x:x86_64" + }, "srcDir" : { "type" : "string", "description" : "Путь к корневому каталогу с исходниками конфигурации, в случае хранения исходников в формате EDT, необходимо указать путь к проекту" diff --git a/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy b/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy index 82b148a..3fcaa6c 100644 --- a/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy +++ b/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy @@ -12,6 +12,9 @@ class JobConfiguration implements Serializable { @JsonPropertyDescription("Версия платформы 1С:Предприятие в формате 8.3.хх.хххх.") String v8version + @JsonPropertyDescription("Версия модуля 1C:Enterprise Development Tools формате xxxx.x.x:x86_64") + String edtVersion + @JsonPropertyDescription("Путь к корневому каталогу с исходниками конфигурации, в случае хранения исходников в формате EDT, необходимо указать путь к проекту") String srcDir @@ -65,6 +68,7 @@ class JobConfiguration implements Serializable { String toString() { return "JobConfiguration{" + "v8version='" + v8version + '\'' + + ", edtVersion='" + edtVersion + '\'' + ", srcDir='" + srcDir + '\'' + ", sourceFormat=" + sourceFormat + ", stageFlags=" + stageFlags + diff --git a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy index e62a336..f682183 100644 --- a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy @@ -39,7 +39,12 @@ class DesignerToEdtFormatTransformation implements Serializable { Logger.println("Конвертация исходников из формата конфигуратора в формат EDT") - def ringCommand = "ring edt workspace import --configuration-files \"$configurationRoot\" --project-name $PROJECT_NAME --workspace-location \"$workspaceDir\"" + String edtVersion = "edt" + if (config.edtVersion != '') { + edtVersion += "@" + config.edtVersion + } + + def ringCommand = "ring $edtVersion workspace import --configuration-files \"$configurationRoot\" --project-name $PROJECT_NAME --workspace-location \"$workspaceDir\"" def ringOpts = [Constants.DEFAULT_RING_OPTS] steps.withEnv(ringOpts) { From e8097451a32cbc268d90d6f16be68d061a24e5c5 Mon Sep 17 00:00:00 2001 From: ivanmolodec Date: Fri, 13 May 2022 23:07:16 +0300 Subject: [PATCH 03/10] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D1=8E=D0=BD=D0=B8=D1=82-=D1=82=D0=B5=D1=81?= =?UTF-8?q?=D1=82=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=B0?= =?UTF-8?q?=20edtVersion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jenkins/library/configuration/ConfigurationReaderTest.java | 1 + test/unit/resources/jobConfiguration.json | 1 + 2 files changed, 2 insertions(+) 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 64d2d3b..5e789f1 100644 --- a/test/unit/groovy/ru/pulsar/jenkins/library/configuration/ConfigurationReaderTest.java +++ b/test/unit/groovy/ru/pulsar/jenkins/library/configuration/ConfigurationReaderTest.java @@ -31,6 +31,7 @@ class ConfigurationReaderTest { // then assertThat(jobConfiguration.getV8version()).isEqualTo("8.3.14.1944"); + assertThat(jobConfiguration.getEdtVersion()).isEqualTo("2021.3.4:x86_64"); assertThat(jobConfiguration.getSonarQubeOptions().getSonarScannerToolName()).isEqualTo("sonar-scanner"); assertThat(jobConfiguration.getSonarQubeOptions().getSonarQubeInstallation()).isEqualTo("qa"); diff --git a/test/unit/resources/jobConfiguration.json b/test/unit/resources/jobConfiguration.json index a4205c1..5a57c44 100644 --- a/test/unit/resources/jobConfiguration.json +++ b/test/unit/resources/jobConfiguration.json @@ -1,5 +1,6 @@ { "v8version": "8.3.14.1944", + "edtVersion": "2021.3.4:x86_64", "secrets": { "storage": "1234" }, From a996536981a42e03a5eca5f73f438c70eaf80002 Mon Sep 17 00:00:00 2001 From: ivanmolodec Date: Fri, 13 May 2022 23:14:19 +0300 Subject: [PATCH 04/10] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=B0=D1=80=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D1=80=D0=B0=20edtVersion=20=D0=B2=20=D1=88?= =?UTF-8?q?=D0=B0=D0=B3=D0=B0=D1=85=20EdtValidate=20=D0=B8=20EdtToDesigner?= =?UTF-8?q?FormatTransformation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/steps/EdtToDesignerFormatTransformation.groovy | 7 ++++++- src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy index 57ccf62..7c8e299 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy @@ -43,7 +43,12 @@ class EdtToDesignerFormatTransformation implements Serializable { Logger.println("Конвертация исходников из формата EDT в формат Конфигуратора") - def ringCommand = "ring edt workspace export --workspace-location \"$workspaceDir\" --project \"$projectDir\" --configuration-files \"$configurationRoot\"" + String edtVersion = "edt" + if (config.edtVersion != '') { + edtVersion += "@" + config.edtVersion + } + + def ringCommand = "ring $edtVersion workspace export --workspace-location \"$workspaceDir\" --project \"$projectDir\" --configuration-files \"$configurationRoot\"" def ringOpts = [Constants.DEFAULT_RING_OPTS] steps.withEnv(ringOpts) { diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index 1e29990..8ccd4a8 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -47,7 +47,12 @@ class EdtValidate implements Serializable { Logger.println("Выполнение валидации EDT") - def ringCommand = "ring edt workspace validate --workspace-location \"$workspaceLocation\" --file \"$resultFile\" $projectList" + String edtVersion = "edt" + if (config.edtVersion != '') { + edtVersion += "@" + config.edtVersion + } + + def ringCommand = "ring $edtVersion workspace validate --workspace-location \"$workspaceLocation\" --file \"$resultFile\" $projectList" def ringOpts = [Constants.DEFAULT_RING_OPTS] steps.withEnv(ringOpts) { steps.catchError { From f07eb03d7a320c75ba5197fd6922d0e6f8ef542e Mon Sep 17 00:00:00 2001 From: ivanmolodec Date: Fri, 13 May 2022 23:37:42 +0300 Subject: [PATCH 05/10] =?UTF-8?q?=EF=BB=BF=D0=9F=D1=80=D0=B8=D0=B2=D1=8F?= =?UTF-8?q?=D0=B7=D0=B0=D0=BD=D0=B0=20=D0=BC=D0=B5=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=BA=D0=B5=D1=80-=D0=B0=D0=B3=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=20=D0=BA=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D1=80=D1=83=20edtVersion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vars/pipeline1C.groovy | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/vars/pipeline1C.groovy b/vars/pipeline1C.groovy index 227924d..5ac665e 100644 --- a/vars/pipeline1C.groovy +++ b/vars/pipeline1C.groovy @@ -11,6 +11,9 @@ JobConfiguration config @Field String agent1C +@Field +String agentEdt + void call() { //noinspection GroovyAssignabilityCheck @@ -36,6 +39,10 @@ void call() { script { config = jobConfiguration() as JobConfiguration agent1C = config.v8version + agentEdt = "edt" + if (config.edtVersion != '') { + agentEdt += "@" + config.edtVersion + } } } } @@ -54,7 +61,7 @@ void call() { stages { stage('Трансформация из формата EDT') { agent { - label 'edt' + label agentEdt } when { beforeAgent true @@ -114,7 +121,7 @@ void call() { stage('Трансформация в формат EDT') { agent { - label 'edt' + label agentEdt } when { beforeAgent true @@ -139,7 +146,7 @@ void call() { stages { stage('Валидация EDT') { agent { - label 'edt' + label agentEdt } steps { timeout(time: config.timeoutOptions.edtValidate, unit: TimeUnit.MINUTES) { From fade78500350bb878a78ca798e08df1005eec100 Mon Sep 17 00:00:00 2001 From: Ivan Smirnov <52702497+ivanmolodec@users.noreply.github.com> Date: Fri, 13 May 2022 23:52:42 +0300 Subject: [PATCH 06/10] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=B8=D0=BD=D1=84=D0=BE=D1=80=D0=BC=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D0=BF=D0=BE=20=D0=BF=D0=B0=D1=80=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D1=80=D1=83=20edtVersion=20=D0=B2=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 51ec393..559e0d6 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ 1. Для шага подготовки требуется любой агент с меткой `agent`. 1. Для запуска шага анализа SonarQube требуется агент с меткой `sonar`. -1. Для запуска шагов, работающих с EDT (валидация, трансформация формата исходников) требуется агент с меткой `edt` и агент с меткой `oscript`, на котором глобально установлена библиотека [stebi](https://github.com/Stepa86/stebi) версии 1.9.1 или новее. +1. Для запуска шагов, работающих с EDT (валидация, трансформация формата исходников) требуется агент с меткой `edt` (если используется несколько версий EDT необходимо к метке добавить версию, например `edt@2021.3.4:x86_64`) и агент с меткой `oscript`, на котором глобально установлена библиотека [stebi](https://github.com/Stepa86/stebi) версии 1.9.1 или новее. 1. Для запуска шагов, работающих с 1С (подготовка, синтаксический контроль и т.д.) требуется агент с меткой, совпадающей со значением в поле `v8version` файла конфигурации. 1. В качестве ИБ используется файловая база, создаваемая в каталоге `./build/ib`. При необходимости вы можете создать пользователей на фазе инициализации ИБ. @@ -76,6 +76,7 @@ pipeline1C() Пример переопределения: * указывается точная версия платформы (и соответственно метка агента, см. ограничения) +* указывается точная версия модуля EDT (и соответственно метка агента, см. ограничения) * идентификаторы credentials для пути к хранилищу и к паре логин/пароль для авторизации в хранилище (необходимы, если применяются шаги, работающие с информационной базой) * включаются шаги запуска статического анализа SonarQube, валидации средствами EDT и синтаксического контроля @@ -83,6 +84,7 @@ pipeline1C() { "$schema": "https://raw.githubusercontent.com/firstBitSemenovskaya/jenkins-lib/master/resources/schema.json", "v8version": "8.3.14.1976", + "edtVersion": "2021.3.4:x86_64", "secrets": { "storagePath": "f7b21c02-711a-4883-81c5-d429454e3f8b", "storage" : "c1fc5f33-67d4-493f-a2a4-97d3040e4b8c" @@ -103,6 +105,7 @@ pipeline1C() * Общее: * В качестве маски версии платформы используется строка "8.3" (`v8version`). + * По-умолчанию версия модуля EDT не заполнена, т.к. в случае единственной версии для утилиты ring дополнительного указания не требуется (`edtVersion`). * Исходники конфигурации ожидаются в каталоге `src/cf` (`srcDir`). * Формат исходников - выгрузка из Конфигуратора (`sourceFormat`). * Ветка по умолчанию (для комбинированного режима загрузки конфигурации) - "main" (`defaultBranch`). From 8c5b53a7a8a561ef5e1e1b462d91d5fc215c211c Mon Sep 17 00:00:00 2001 From: ivanmolodec Date: Sun, 15 May 2022 19:19:52 +0300 Subject: [PATCH 07/10] =?UTF-8?q?=EF=BB=BF=D0=94=D0=BE=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=D0=BD=D1=8B=20=D1=8E=D0=BD=D0=B8=D1=82-?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4?= =?UTF-8?q?=D0=BE=D0=B2=20JobConfiguration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConfigurationReaderTest.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) 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 5e789f1..3d324b3 100644 --- a/test/unit/groovy/ru/pulsar/jenkins/library/configuration/ConfigurationReaderTest.java +++ b/test/unit/groovy/ru/pulsar/jenkins/library/configuration/ConfigurationReaderTest.java @@ -2,6 +2,7 @@ package ru.pulsar.jenkins.library.configuration; import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import ru.pulsar.jenkins.library.utils.TestUtils; @@ -62,4 +63,52 @@ class ConfigurationReaderTest { assertThat(jobConfiguration.getTimeoutOptions().getZipInfoBase()).isEqualTo(123); } + @Test + void testV8versionMethod() throws IOException { + // given + String config = IOUtils.resourceToString( + "jobConfiguration.json", + StandardCharsets.UTF_8, + this.getClass().getClassLoader() + ); + + // when + JobConfiguration jobConfiguration = ConfigurationReader.create(config); + + // then + assertThat(jobConfiguration.v8version()).isEqualTo("8.3.14.1944"); + } + + @Test + void testEdtVersionForRingMethod() throws IOException { + // given + String config = IOUtils.resourceToString( + "jobConfiguration.json", + StandardCharsets.UTF_8, + this.getClass().getClassLoader() + ); + + // when + JobConfiguration jobConfiguration = ConfigurationReader.create(config); + + // then + assertThat(jobConfiguration.edtVersionForRing()).isEqualTo("edt@2021.3.4:x86_64"); + } + + @Disabled + void testinfoBaseFromFilesMethod() throws IOException { + // given + String config = IOUtils.resourceToString( + "jobConfiguration.json", + StandardCharsets.UTF_8, + this.getClass().getClassLoader() + ); + + // when + JobConfiguration jobConfiguration = ConfigurationReader.create(config); + + // then + assertThat(jobConfiguration.infoBaseFromFiles()).isFalse(); + } + } \ No newline at end of file From 6cf6aee4724810ea7f9231a3bb8cc154821489f3 Mon Sep 17 00:00:00 2001 From: ivanmolodec Date: Mon, 16 May 2022 11:15:33 +0300 Subject: [PATCH 08/10] =?UTF-8?q?=D0=9C=D0=B5=D1=82=D0=BE=D0=B4=D1=8B=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B8=20=D0=B0=D0=B3=D0=B5=D0=BD=D1=82=D0=B0?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=201=D1=81=20=D0=B8=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=B5=D0=B4=D1=82=20=D0=B2=D0=BD=D0=B5=D1=81=D0=B5=D0=BD?= =?UTF-8?q?=D1=8B=20=D0=B2=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20JobConfigura?= =?UTF-8?q?tion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/configuration/JobConfiguration.groovy | 12 ++++++++++++ .../steps/DesignerToEdtFormatTransformation.groovy | 8 ++------ .../steps/EdtToDesignerFormatTransformation.groovy | 8 ++------ .../pulsar/jenkins/library/steps/EdtValidate.groovy | 8 ++------ vars/pipeline1C.groovy | 7 ++----- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy b/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy index 3fcaa6c..24e600c 100644 --- a/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy +++ b/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy @@ -94,4 +94,16 @@ class JobConfiguration implements Serializable { return (initMethod == InitInfoBaseMethod.FROM_SOURCE) || (initMethod == InitInfoBaseMethod.DEFAULT_BRANCH_FROM_STORAGE && branchName != defaultBranch) } + + String v8version() { + return v8version + } + + String edtVersionForRing() { + String edtVersionForRing = "edt" + if (edtVersion != '') { + edtVersionForRing += "@" + edtVersion + } + return edtVersionForRing + } } \ No newline at end of file diff --git a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy index f682183..e0e30db 100644 --- a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy @@ -34,17 +34,13 @@ class DesignerToEdtFormatTransformation implements Serializable { def workspaceDir = "$env.WORKSPACE/$WORKSPACE" def configurationRoot = new File(env.WORKSPACE, config.srcDir).getAbsolutePath() + def edtVersionForRing = config.edtVersionForRing() steps.deleteDir(workspaceDir) Logger.println("Конвертация исходников из формата конфигуратора в формат EDT") - String edtVersion = "edt" - if (config.edtVersion != '') { - edtVersion += "@" + config.edtVersion - } - - def ringCommand = "ring $edtVersion workspace import --configuration-files \"$configurationRoot\" --project-name $PROJECT_NAME --workspace-location \"$workspaceDir\"" + def ringCommand = "ring $edtVersionForRing workspace import --configuration-files \"$configurationRoot\" --project-name $PROJECT_NAME --workspace-location \"$workspaceDir\"" def ringOpts = [Constants.DEFAULT_RING_OPTS] steps.withEnv(ringOpts) { diff --git a/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy index 7c8e299..a3fef79 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy @@ -37,18 +37,14 @@ class EdtToDesignerFormatTransformation implements Serializable { def projectDir = new File("$env.WORKSPACE/$srcDir").getCanonicalPath() def workspaceDir = "$env.WORKSPACE/$WORKSPACE" def configurationRoot = "$env.WORKSPACE/$CONFIGURATION_DIR" + def edtVersionForRing = config.edtVersionForRing() steps.deleteDir(workspaceDir) steps.deleteDir(configurationRoot) Logger.println("Конвертация исходников из формата EDT в формат Конфигуратора") - String edtVersion = "edt" - if (config.edtVersion != '') { - edtVersion += "@" + config.edtVersion - } - - def ringCommand = "ring $edtVersion workspace export --workspace-location \"$workspaceDir\" --project \"$projectDir\" --configuration-files \"$configurationRoot\"" + def ringCommand = "ring $edtVersionForRing workspace export --workspace-location \"$workspaceDir\" --project \"$projectDir\" --configuration-files \"$configurationRoot\"" def ringOpts = [Constants.DEFAULT_RING_OPTS] steps.withEnv(ringOpts) { diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index 8ccd4a8..a6d83cf 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -44,15 +44,11 @@ class EdtValidate implements Serializable { } def resultFile = "$env.WORKSPACE/$RESULT_FILE" + def edtVersionForRing = config.edtVersionForRing() Logger.println("Выполнение валидации EDT") - String edtVersion = "edt" - if (config.edtVersion != '') { - edtVersion += "@" + config.edtVersion - } - - def ringCommand = "ring $edtVersion workspace validate --workspace-location \"$workspaceLocation\" --file \"$resultFile\" $projectList" + def ringCommand = "ring $edtVersionForRing workspace validate --workspace-location \"$workspaceLocation\" --file \"$resultFile\" $projectList" def ringOpts = [Constants.DEFAULT_RING_OPTS] steps.withEnv(ringOpts) { steps.catchError { diff --git a/vars/pipeline1C.groovy b/vars/pipeline1C.groovy index 5ac665e..8f49620 100644 --- a/vars/pipeline1C.groovy +++ b/vars/pipeline1C.groovy @@ -38,11 +38,8 @@ void call() { steps { script { config = jobConfiguration() as JobConfiguration - agent1C = config.v8version - agentEdt = "edt" - if (config.edtVersion != '') { - agentEdt += "@" + config.edtVersion - } + agent1C = config.v8version() + agentEdt = config.edtVersionForRing() } } } From 0bfb927b282a7e7dac8a7046282da96f0295f4a3 Mon Sep 17 00:00:00 2001 From: ivanmolodec Date: Mon, 16 May 2022 12:17:16 +0300 Subject: [PATCH 09/10] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B8=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D1=8B=20=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D0=BE=D0=B4=D1=8B=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B8=D0=BC=D0=B5=D0=BD=D0=B8=20=D0=B0=D0=B3?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B0=20=D0=B4=D0=BB=D1=8F=201=D1=81=20?= =?UTF-8?q?=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D0=B5=D0=B4=D1=82=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B5=20JobConfiguration,=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D1=81=20EDT,=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BE?= =?UTF-8?q?=D0=BF=D1=80=D0=B5=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=B2?= =?UTF-8?q?=D1=8B=D0=B7=D0=BE=D0=B2=D1=8B=20=D0=B2=20=D1=88=D0=B0=D0=B3?= =?UTF-8?q?=D0=B0=D1=85=20EDT=20=D0=BD=D0=B0=20=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=B4=20=D0=B2=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=BC=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D1=81=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configuration/JobConfiguration.groovy | 4 +- .../DesignerToEdtFormatTransformation.groovy | 3 +- .../EdtToDesignerFormatTransformation.groovy | 3 +- .../jenkins/library/steps/EdtValidate.groovy | 3 +- .../pulsar/jenkins/library/utils/EDT.groovy | 12 ++++++ .../ConfigurationReaderTest.java | 10 ++--- .../pulsar/jenkins/library/utils/EDTTest.java | 39 +++++++++++++++++++ vars/pipeline1C.groovy | 4 +- 8 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 src/ru/pulsar/jenkins/library/utils/EDT.groovy create mode 100644 test/unit/groovy/ru/pulsar/jenkins/library/utils/EDTTest.java diff --git a/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy b/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy index 24e600c..066e672 100644 --- a/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy +++ b/src/ru/pulsar/jenkins/library/configuration/JobConfiguration.groovy @@ -95,11 +95,11 @@ class JobConfiguration implements Serializable { (initMethod == InitInfoBaseMethod.DEFAULT_BRANCH_FROM_STORAGE && branchName != defaultBranch) } - String v8version() { + String v8AgentLabel() { return v8version } - String edtVersionForRing() { + String edtAgentLabel() { String edtVersionForRing = "edt" if (edtVersion != '') { edtVersionForRing += "@" + edtVersion diff --git a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy index e0e30db..7ae969d 100644 --- a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy @@ -5,6 +5,7 @@ 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.Constants +import ru.pulsar.jenkins.library.utils.EDT import ru.pulsar.jenkins.library.utils.Logger class DesignerToEdtFormatTransformation implements Serializable { @@ -34,7 +35,7 @@ class DesignerToEdtFormatTransformation implements Serializable { def workspaceDir = "$env.WORKSPACE/$WORKSPACE" def configurationRoot = new File(env.WORKSPACE, config.srcDir).getAbsolutePath() - def edtVersionForRing = config.edtVersionForRing() + def edtVersionForRing = EDT.ringModule(config) steps.deleteDir(workspaceDir) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy index a3fef79..65d67e8 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy @@ -6,6 +6,7 @@ import ru.pulsar.jenkins.library.configuration.JobConfiguration import ru.pulsar.jenkins.library.configuration.SourceFormat import ru.pulsar.jenkins.library.ioc.ContextRegistry import ru.pulsar.jenkins.library.utils.Constants +import ru.pulsar.jenkins.library.utils.EDT import ru.pulsar.jenkins.library.utils.Logger class EdtToDesignerFormatTransformation implements Serializable { @@ -37,7 +38,7 @@ class EdtToDesignerFormatTransformation implements Serializable { def projectDir = new File("$env.WORKSPACE/$srcDir").getCanonicalPath() def workspaceDir = "$env.WORKSPACE/$WORKSPACE" def configurationRoot = "$env.WORKSPACE/$CONFIGURATION_DIR" - def edtVersionForRing = config.edtVersionForRing() + def edtVersionForRing = EDT.ringModule(config) steps.deleteDir(workspaceDir) steps.deleteDir(configurationRoot) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index a6d83cf..c9f2727 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -5,6 +5,7 @@ import ru.pulsar.jenkins.library.configuration.JobConfiguration import ru.pulsar.jenkins.library.configuration.SourceFormat import ru.pulsar.jenkins.library.ioc.ContextRegistry import ru.pulsar.jenkins.library.utils.Constants +import ru.pulsar.jenkins.library.utils.EDT import ru.pulsar.jenkins.library.utils.Logger class EdtValidate implements Serializable { @@ -44,7 +45,7 @@ class EdtValidate implements Serializable { } def resultFile = "$env.WORKSPACE/$RESULT_FILE" - def edtVersionForRing = config.edtVersionForRing() + def edtVersionForRing = EDT.ringModule(config) Logger.println("Выполнение валидации EDT") diff --git a/src/ru/pulsar/jenkins/library/utils/EDT.groovy b/src/ru/pulsar/jenkins/library/utils/EDT.groovy new file mode 100644 index 0000000..cb4f5c3 --- /dev/null +++ b/src/ru/pulsar/jenkins/library/utils/EDT.groovy @@ -0,0 +1,12 @@ +package ru.pulsar.jenkins.library.utils + +import ru.pulsar.jenkins.library.configuration.JobConfiguration + +final class EDT { + + static String ringModule(JobConfiguration config) { + return config.edtAgentLabel() + } + +} + 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 3d324b3..a8b81f0 100644 --- a/test/unit/groovy/ru/pulsar/jenkins/library/configuration/ConfigurationReaderTest.java +++ b/test/unit/groovy/ru/pulsar/jenkins/library/configuration/ConfigurationReaderTest.java @@ -64,7 +64,7 @@ class ConfigurationReaderTest { } @Test - void testV8versionMethod() throws IOException { + void testV8AgentLabel() throws IOException { // given String config = IOUtils.resourceToString( "jobConfiguration.json", @@ -76,11 +76,11 @@ class ConfigurationReaderTest { JobConfiguration jobConfiguration = ConfigurationReader.create(config); // then - assertThat(jobConfiguration.v8version()).isEqualTo("8.3.14.1944"); + assertThat(jobConfiguration.v8AgentLabel()).isEqualTo("8.3.14.1944"); } @Test - void testEdtVersionForRingMethod() throws IOException { + void testEdtAgentLabel() throws IOException { // given String config = IOUtils.resourceToString( "jobConfiguration.json", @@ -92,11 +92,11 @@ class ConfigurationReaderTest { JobConfiguration jobConfiguration = ConfigurationReader.create(config); // then - assertThat(jobConfiguration.edtVersionForRing()).isEqualTo("edt@2021.3.4:x86_64"); + assertThat(jobConfiguration.edtAgentLabel()).isEqualTo("edt@2021.3.4:x86_64"); } @Disabled - void testinfoBaseFromFilesMethod() throws IOException { + void testInfoBaseFromFiles() throws IOException { // given String config = IOUtils.resourceToString( "jobConfiguration.json", diff --git a/test/unit/groovy/ru/pulsar/jenkins/library/utils/EDTTest.java b/test/unit/groovy/ru/pulsar/jenkins/library/utils/EDTTest.java new file mode 100644 index 0000000..4947c3c --- /dev/null +++ b/test/unit/groovy/ru/pulsar/jenkins/library/utils/EDTTest.java @@ -0,0 +1,39 @@ +package ru.pulsar.jenkins.library.utils; + +import org.apache.commons.io.IOUtils; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import ru.pulsar.jenkins.library.configuration.ConfigurationReader; +import ru.pulsar.jenkins.library.configuration.JobConfiguration; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +import static org.assertj.core.api.Assertions.assertThat; + +class EDTTest { + + @BeforeEach + void setUp() { + TestUtils.setupMockedContext(); + } + + @Test + void testRingModule() throws IOException { + + // given + String config = IOUtils.resourceToString( + "jobConfiguration.json", + StandardCharsets.UTF_8, + this.getClass().getClassLoader() + ); + + // when + JobConfiguration jobConfiguration = ConfigurationReader.create(config); + String edtModule = EDT.ringModule(jobConfiguration); + + // then + assertThat(edtModule).isEqualTo("edt@2021.3.4:x86_64"); + } + +} \ No newline at end of file diff --git a/vars/pipeline1C.groovy b/vars/pipeline1C.groovy index 8f49620..d59bce6 100644 --- a/vars/pipeline1C.groovy +++ b/vars/pipeline1C.groovy @@ -38,8 +38,8 @@ void call() { steps { script { config = jobConfiguration() as JobConfiguration - agent1C = config.v8version() - agentEdt = config.edtVersionForRing() + agent1C = config.v8AgentLabel() + agentEdt = config.edtAgentLabel() } } } From 16815f2b6e0396464acbc16555bba00eabe350c8 Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Fri, 20 May 2022 10:58:48 +0300 Subject: [PATCH 10/10] =?UTF-8?q?=D0=97=D0=B0=D0=BC=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BE=D0=B4=D0=B8=D0=BD=D0=B0=D1=80=D0=BD=D1=8B=D1=85=20=D0=BA?= =?UTF-8?q?=D0=B0=D0=B2=D1=8B=D1=87=D0=B5=D0=BA,=20=D0=B2=D1=8B=D0=B7?= =?UTF-8?q?=D1=8B=D0=B2=D0=B0=D1=8E=D1=89=D0=B8=D1=85=20=D0=BE=D1=88=D0=B8?= =?UTF-8?q?=D0=B1=D0=BA=D1=83=20=D0=BF=D1=80=D0=B8=20=D0=BF=D0=BE=D0=BF?= =?UTF-8?q?=D1=8B=D1=82=D0=BA=D0=B5=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4?= =?UTF-8?q?=D1=8B=20ring=20validate?= 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 c9f2727..98c8f6d 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 { projectList = "--project-name-list $DesignerToEdtFormatTransformation.PROJECT_NAME" } else { String projectDir = new File("$env.WORKSPACE/$config.srcDir").getCanonicalPath() - projectList = "--project-list '$projectDir'" + projectList = "--project-list \"$projectDir\"" } def resultFile = "$env.WORKSPACE/$RESULT_FILE"