From b1481398ca059f980cc5de18d9c6afb85fd1e9d1 Mon Sep 17 00:00:00 2001 From: Oleg Karataev Date: Wed, 1 Jan 2025 11:33:18 +0300 Subject: [PATCH 01/10] =?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=B4=D0=BE=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LICENSE.md | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 7d5045b8..b40270f1 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,25 +1,25 @@ -The MIT License (MIT) -===================== - -Copyright © `2020` `First Bit Semenovskaya, Первый Бит Семеновская` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. +The MIT License (MIT) +===================== + +Copyright © `2020` `First Bit Semenovskaya, Первый Бит Семеновская` + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the “Software”), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. From 1ef5a0fcc73df133fe02335304da5ab8bbdc623d Mon Sep 17 00:00:00 2001 From: Oleg Karataev Date: Wed, 1 Jan 2025 21:57:27 +0300 Subject: [PATCH 02/10] =?UTF-8?q?=D0=97=D0=B0=D0=BA=D0=BE=D0=BC=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BE=20?= =?UTF-8?q?pathToJUnitReport.copyTo(pathToAllureReport)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy b/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy index 317059e0..79edb9a3 100644 --- a/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy +++ b/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy @@ -86,7 +86,8 @@ class Yaxunit implements Serializable, Coverable { FilePath pathToAllureReport = FileUtils.getFilePath("$env.WORKSPACE/$allureReport") String allureReportDir = FileUtils.getLocalPath(pathToAllureReport.getParent()) - pathToJUnitReport.copyTo(pathToAllureReport) + // * Закомментировано, т.к. ошибка формирования отчета allure + //pathToJUnitReport.copyTo(pathToAllureReport) steps.stash(YAXUNIT_ALLURE_STASH, "$allureReportDir/**", true) } From 038706d52831079a8fe1d00007f6e2851db067f6 Mon Sep 17 00:00:00 2001 From: Oleg Karataev Date: Fri, 3 Jan 2025 14:15:59 +0300 Subject: [PATCH 03/10] =?UTF-8?q?fix:=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BF=D1=83=D0=B1=D0=BB=D0=B8=D0=BA=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=BF=D0=BE=20=D0=B2=D0=BB=D0=BE=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D0=BC=20=D0=BF=D0=B0=D0=BF=D0=BA=D0=B0=D0=BC?= =?UTF-8?q?=20=D0=B2=20/build/out/allure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/steps/PublishAllure.groovy | 47 +++++++++++++++++-- .../jenkins/library/utils/FileUtils.groovy | 8 +++- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/PublishAllure.groovy b/src/ru/pulsar/jenkins/library/steps/PublishAllure.groovy index 40a58d6a..521656d7 100644 --- a/src/ru/pulsar/jenkins/library/steps/PublishAllure.groovy +++ b/src/ru/pulsar/jenkins/library/steps/PublishAllure.groovy @@ -17,11 +17,10 @@ class PublishAllure implements Serializable { } def run() { - Logger.printLocation() if (config == null) { - Logger.println("jobConfiguration is not initialized") + Logger.println('jobConfiguration is not initialized') return } @@ -44,16 +43,37 @@ class PublishAllure implements Serializable { FilePath allurePath = FileUtils.getFilePath("$env.WORKSPACE/build/out/allure") if (!allurePath.exists()) { - Logger.println("Отсутствуют результаты allure для публикации") + Logger.println('Отсутствуют результаты allure для публикации') return } List results = new ArrayList<>() + int directoryCount = allurePath.listDirectories().size() + Logger.println("Log: Количество подкаталогов в $allurePath: $directoryCount") + + FilePath workSpacePath = FileUtils.getFilePath("$env.WORKSPACE") + String basePath = replaceBackslashesWithSlashes(workSpacePath.toString()) + Logger.println("Log: workSpacePath = $workSpacePath, basePath = $basePath") + allurePath.listDirectories().each { FilePath filePath -> - results.add(FileUtils.getLocalPath(filePath)) + FilePath pathCurrent = FileUtils.getFilePath("$filePath") + String pathdir = FileUtils.getLocalPath(pathCurrent) + Logger.println("Log: pathCurrent = $pathCurrent, pathdir = $pathdir") + + String rezultPath = getRelativePath(pathdir, basePath) + Logger.println("Log: pathdir = $pathdir, basePath = $basePath. Результат через getRelativePath() = $rezultPath") + results.add(rezultPath) + + //String pathdir = FileUtils.getLocalPath(filePath) + //results.add(FileUtils.getLocalPath(filePath)) + //Logger.println("Log: Результат для добавления в allure getLocalPath($pathCurrent): $pathdir") } + + String pathAllure = FileUtils.getLocalPath(allurePath) + Logger.println("Log: если в подкаталогах allure пусто, то будет добавлен только путь на основе getLocalPath($allurePath): $pathAllure") if (results.isEmpty()) { + Logger.println('Log: результат пустой и фиксиурем путь выше') results.add(FileUtils.getLocalPath(allurePath)) } @@ -67,4 +87,23 @@ class PublishAllure implements Serializable { Logger.println("Can't unstash $stashName") } } + + private static replaceBackslashesWithSlashes(String path) { + return path.replace('\\', '/') + } + + private static String getRelativePath(String absolutePath, String basePath) { + def normalizedAbsolutePath = new File(absolutePath).canonicalPath + def normalizedBasePath = new File(basePath).canonicalPath + + def relativePath = normalizedAbsolutePath.replaceFirst(normalizedBasePath, '') + + // Убираем начальный '/' если он есть + if (relativePath.startsWith('/')) { + relativePath = relativePath.substring(1) + } + + return relativePath + } + } diff --git a/src/ru/pulsar/jenkins/library/utils/FileUtils.groovy b/src/ru/pulsar/jenkins/library/utils/FileUtils.groovy index 721f6800..e5b2283b 100644 --- a/src/ru/pulsar/jenkins/library/utils/FileUtils.groovy +++ b/src/ru/pulsar/jenkins/library/utils/FileUtils.groovy @@ -35,11 +35,17 @@ class FileUtils { Path workspacePath = new File(env.WORKSPACE).toPath() Path rawFilePath = new File(filePath.getRemote()).toPath() - return workspacePath.relativize(rawFilePath) + def str = workspacePath.relativize(rawFilePath) .toString() .replaceAll('\\\\\\\\', '/') .replaceAll('\\\\', '/') .toString() + + if (str.startsWith("../")) { + str = str.substring(3) + } + + return str } static void loadFile(String filePathFrom, def env, String filePathTo) { From c9d72e99c57556b1beee7671351521b933035c00 Mon Sep 17 00:00:00 2001 From: Oleg Karataev Date: Wed, 8 Jan 2025 17:11:05 +0300 Subject: [PATCH 04/10] =?UTF-8?q?=D0=9A=D0=BE=D1=80=D1=80=D0=B5=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=B2=D1=8B=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=20=D1=81=D0=BE=D0=BD=D0=B0=D1=80=D0=B0=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20auto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy b/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy index 4c0494a7..ae7e5fce 100644 --- a/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy +++ b/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy @@ -52,6 +52,7 @@ class SonarScanner implements Serializable { } } else (branchAnalysisConfiguration == BranchAnalysisConfiguration.AUTO) { // no-op + sonarCommand += "" } String projectVersion = computeProjectVersion() From f2308b93781473fa6cd9a983c84b94cf4c66ca76 Mon Sep 17 00:00:00 2001 From: Oleg Karataev Date: Wed, 8 Jan 2025 17:16:56 +0300 Subject: [PATCH 05/10] =?UTF-8?q?=D0=9A=D0=BE=D1=80=D1=80=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BD=D0=B0=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B5=D0=BA=20=D1=81=D0=BE=D0=BD=D0=B0=D1=80?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20AUTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy b/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy index ae7e5fce..92baf444 100644 --- a/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy +++ b/src/ru/pulsar/jenkins/library/steps/SonarScanner.groovy @@ -50,9 +50,8 @@ class SonarScanner implements Serializable { } else { sonarCommand += " -Dsonar.branch.name=$env.BRANCH_NAME" } - } else (branchAnalysisConfiguration == BranchAnalysisConfiguration.AUTO) { + } else if (branchAnalysisConfiguration == BranchAnalysisConfiguration.AUTO) { // no-op - sonarCommand += "" } String projectVersion = computeProjectVersion() From d4eaa81e27f42f4ef68a7ff6935c0e2288fd3d31 Mon Sep 17 00:00:00 2001 From: Nikita Fedkin Date: Fri, 24 Jan 2025 18:55:45 +0100 Subject: [PATCH 06/10] =?UTF-8?q?=D0=94=D1=80=D1=83=D0=B3=D0=BE=D0=B9=20?= =?UTF-8?q?=D1=81=D0=BF=D0=BE=D1=81=D0=BE=D0=B1=20=D1=80=D0=B0=D1=81=D1=87?= =?UTF-8?q?=D0=B5=D1=82=D0=B0=20=D0=BB=D0=BE=D0=BA=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D0=BE=D0=B3=D0=BE=20FilePath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jenkins/library/utils/FileUtils.groovy | 19 ++++++----- .../jenkins/library/utils/EnvUtils.java | 2 +- .../jenkins/library/utils/FileUtilsTest.java | 32 +++++++++++++++++++ 3 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 test/unit/groovy/ru/pulsar/jenkins/library/utils/FileUtilsTest.java diff --git a/src/ru/pulsar/jenkins/library/utils/FileUtils.groovy b/src/ru/pulsar/jenkins/library/utils/FileUtils.groovy index 721f6800..d64288df 100644 --- a/src/ru/pulsar/jenkins/library/utils/FileUtils.groovy +++ b/src/ru/pulsar/jenkins/library/utils/FileUtils.groovy @@ -29,17 +29,20 @@ class FileUtils { static String getLocalPath(FilePath filePath) { IStepExecutor steps = ContextRegistry.getContext().getStepExecutor() + String workspacePath = steps.env().WORKSPACE + String fileRemotePath = filePath.getRemote() - def env = steps.env(); + // Нормализуем пути: заменяем обратные слэши на прямые + workspacePath = workspacePath.replace('\\', '/') + fileRemotePath = fileRemotePath.replace('\\', '/') - Path workspacePath = new File(env.WORKSPACE).toPath() - Path rawFilePath = new File(filePath.getRemote()).toPath() + // Проверяем, что файл находится внутри рабочей директории + if (!fileRemotePath.startsWith(workspacePath)) { + throw new IllegalArgumentException("File path is not within the workspace directory") + } - return workspacePath.relativize(rawFilePath) - .toString() - .replaceAll('\\\\\\\\', '/') - .replaceAll('\\\\', '/') - .toString() + // Вычисляем относительный путь + return fileRemotePath.substring(workspacePath.length() + 1) } static void loadFile(String filePathFrom, def env, String filePathTo) { diff --git a/test/unit/groovy/ru/pulsar/jenkins/library/utils/EnvUtils.java b/test/unit/groovy/ru/pulsar/jenkins/library/utils/EnvUtils.java index 629c6561..618fc8f3 100644 --- a/test/unit/groovy/ru/pulsar/jenkins/library/utils/EnvUtils.java +++ b/test/unit/groovy/ru/pulsar/jenkins/library/utils/EnvUtils.java @@ -7,7 +7,7 @@ public class EnvUtils implements EnvironmentAction { - public String NODE_NAME = "node"; + public String NODE_NAME = "built-in"; public String WORKSPACE = "ws"; public String BRANCH_NAME = "master"; diff --git a/test/unit/groovy/ru/pulsar/jenkins/library/utils/FileUtilsTest.java b/test/unit/groovy/ru/pulsar/jenkins/library/utils/FileUtilsTest.java new file mode 100644 index 00000000..99a6dd89 --- /dev/null +++ b/test/unit/groovy/ru/pulsar/jenkins/library/utils/FileUtilsTest.java @@ -0,0 +1,32 @@ +package ru.pulsar.jenkins.library.utils; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import ru.pulsar.jenkins.library.IStepExecutor; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + +class FileUtilsTest { + + private final IStepExecutor steps = TestUtils.getMockedStepExecutor(); + + @BeforeEach + void setUp() { + TestUtils.setupMockedContext(steps); + } + + @Test + void testGetLocalPath() { + // given + var env = new EnvUtils(); + when(steps.env()).thenReturn(env); + var filePath = FileUtils.getFilePath(env.WORKSPACE + "/src/cf"); + + // when + String localPath = FileUtils.getLocalPath(filePath); + + // then + assertThat(localPath).isEqualTo("src/cf"); + } +} From 26c068778749ef8567bc52e7bab54ad024e87965 Mon Sep 17 00:00:00 2001 From: Oleg Karataev Date: Fri, 24 Jan 2025 21:49:31 +0300 Subject: [PATCH 07/10] Update LICENSE --- LICENSE.md | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 7d5045b8..b40270f1 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,25 +1,25 @@ -The MIT License (MIT) -===================== - -Copyright © `2020` `First Bit Semenovskaya, Первый Бит Семеновская` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. +The MIT License (MIT) +===================== + +Copyright © `2020` `First Bit Semenovskaya, Первый Бит Семеновская` + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the “Software”), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. From f34e1b45ec933ec0d1bf541d049a144162872678 Mon Sep 17 00:00:00 2001 From: Oleg Karataev Date: Fri, 24 Jan 2025 22:08:32 +0300 Subject: [PATCH 08/10] =?UTF-8?q?=D0=92=D0=B5=D1=80=D0=BD=D1=83=D0=BB=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D1=80=D1=8B=D0=B9=20=D0=B2=D0=B0=D1=80=D0=B8?= =?UTF-8?q?=D0=B0=D0=BD=D1=82=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/steps/PublishAllure.groovy | 47 ++----------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/PublishAllure.groovy b/src/ru/pulsar/jenkins/library/steps/PublishAllure.groovy index e51e61a3..638a6cb4 100644 --- a/src/ru/pulsar/jenkins/library/steps/PublishAllure.groovy +++ b/src/ru/pulsar/jenkins/library/steps/PublishAllure.groovy @@ -17,10 +17,11 @@ class PublishAllure implements Serializable { } def run() { + Logger.printLocation() if (config == null) { - Logger.println('jobConfiguration is not initialized') + Logger.println("jobConfiguration is not initialized") return } @@ -46,37 +47,16 @@ class PublishAllure implements Serializable { FilePath allurePath = FileUtils.getFilePath("$env.WORKSPACE/build/out/allure") if (!allurePath.exists()) { - Logger.println('Отсутствуют результаты allure для публикации') + Logger.println("Отсутствуют результаты allure для публикации") return } List results = new ArrayList<>() - int directoryCount = allurePath.listDirectories().size() - Logger.println("Log: Количество подкаталогов в $allurePath: $directoryCount") - - FilePath workSpacePath = FileUtils.getFilePath("$env.WORKSPACE") - String basePath = replaceBackslashesWithSlashes(workSpacePath.toString()) - Logger.println("Log: workSpacePath = $workSpacePath, basePath = $basePath") - allurePath.listDirectories().each { FilePath filePath -> - FilePath pathCurrent = FileUtils.getFilePath("$filePath") - String pathdir = FileUtils.getLocalPath(pathCurrent) - Logger.println("Log: pathCurrent = $pathCurrent, pathdir = $pathdir") - - String rezultPath = getRelativePath(pathdir, basePath) - Logger.println("Log: pathdir = $pathdir, basePath = $basePath. Результат через getRelativePath() = $rezultPath") - results.add(rezultPath) - - //String pathdir = FileUtils.getLocalPath(filePath) - //results.add(FileUtils.getLocalPath(filePath)) - //Logger.println("Log: Результат для добавления в allure getLocalPath($pathCurrent): $pathdir") + results.add(FileUtils.getLocalPath(filePath)) } - - String pathAllure = FileUtils.getLocalPath(allurePath) - Logger.println("Log: если в подкаталогах allure пусто, то будет добавлен только путь на основе getLocalPath($allurePath): $pathAllure") if (results.isEmpty()) { - Logger.println('Log: результат пустой и фиксиурем путь выше') results.add(FileUtils.getLocalPath(allurePath)) } @@ -90,23 +70,4 @@ class PublishAllure implements Serializable { Logger.println("Can't unstash $stashName") } } - - private static replaceBackslashesWithSlashes(String path) { - return path.replace('\\', '/') - } - - private static String getRelativePath(String absolutePath, String basePath) { - def normalizedAbsolutePath = new File(absolutePath).canonicalPath - def normalizedBasePath = new File(basePath).canonicalPath - - def relativePath = normalizedAbsolutePath.replaceFirst(normalizedBasePath, '') - - // Убираем начальный '/' если он есть - if (relativePath.startsWith('/')) { - relativePath = relativePath.substring(1) - } - - return relativePath - } - } From 9388ce8c0c65bfa28a7b96c67fa04d927f47de5f Mon Sep 17 00:00:00 2001 From: Oleg Karataev Date: Sat, 25 Jan 2025 12:56:48 +0300 Subject: [PATCH 09/10] =?UTF-8?q?=D0=92=D0=B5=D1=80=D0=BD=D1=83=D0=BB=20?= =?UTF-8?q?=D0=B1=D0=B0=D0=B7=D0=BE=D0=B2=D1=8B=D0=B9=20=D0=B2=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=B0=D0=BD=D1=82=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B?= =?UTF-8?q?=20=D1=81=20JUnit,=20=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D1=8B=D0=B9?= =?UTF-8?q?=20=D0=B2=D1=8B=D0=B7=D1=8B=D0=B2=D0=B0=D0=B5=D1=82=20=D0=BE?= =?UTF-8?q?=D1=88=D0=B8=D0=B1=D0=BA=D1=83=20=D0=BF=D1=80=D0=B8=20=D1=83?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D0=BE=D0=BC=20=D1=84=D0=BE=D1=80=D0=BC=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B8=20=D0=BE=D1=82=D1=87=D0=B5=D1=82=D0=B0?= =?UTF-8?q?=20=D0=B2=20Allure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy b/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy index c5b2dd78..7bffcc1b 100644 --- a/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy +++ b/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy @@ -86,8 +86,7 @@ class Yaxunit implements Serializable, Coverable { FilePath pathToAllureReport = FileUtils.getFilePath("$env.WORKSPACE/$allureReport") String allureReportDir = FileUtils.getLocalPath(pathToAllureReport.getParent()) - // * Закомментировано, т.к. ошибка формирования отчета allure - //pathToJUnitReport.copyTo(pathToAllureReport) + pathToJUnitReport.copyTo(pathToAllureReport) steps.stash(YAXUNIT_ALLURE_STASH, "$allureReportDir/**", true) } From 609510bf88ff5ca632e19ea5f0a49444242de6ff Mon Sep 17 00:00:00 2001 From: Oleg Karataev Date: Sat, 25 Jan 2025 14:26:31 +0300 Subject: [PATCH 10/10] =?UTF-8?q?fix:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=BE=20=D1=83=D1=81=D0=BB=D0=BE=D0=B2=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20pat?= =?UTF-8?q?hToAllureReport=20junit=20=D0=B2=20yaxunit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy b/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy index 7bffcc1b..43bb739f 100644 --- a/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy +++ b/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy @@ -86,7 +86,10 @@ class Yaxunit implements Serializable, Coverable { FilePath pathToAllureReport = FileUtils.getFilePath("$env.WORKSPACE/$allureReport") String allureReportDir = FileUtils.getLocalPath(pathToAllureReport.getParent()) - pathToJUnitReport.copyTo(pathToAllureReport) + String pathToJUnitReportString = pathToJUnitReport.getRemote() + if (steps.fileExists(pathToJUnitReportString)) { + pathToJUnitReport.copyTo(pathToAllureReport) + } steps.stash(YAXUNIT_ALLURE_STASH, "$allureReportDir/**", true) }