From b1481398ca059f980cc5de18d9c6afb85fd1e9d1 Mon Sep 17 00:00:00 2001 From: Oleg Karataev Date: Wed, 1 Jan 2025 11:33:18 +0300 Subject: [PATCH 1/5] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=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 2/5] =?UTF-8?q?=D0=97=D0=B0=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BE=20pathTo?= =?UTF-8?q?JUnitReport.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 3/5] =?UTF-8?q?fix:=20=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=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BF=D1=83=D0=B1=D0=BB=D0=B8=D0=BA=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=BE=20=D0=B2=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D1=8B=D0=BC=20=D0=BF=D0=B0=D0=BF=D0=BA=D0=B0=D0=BC=20?= =?UTF-8?q?=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 4/5] =?UTF-8?q?=D0=9A=D0=BE=D1=80=D1=80=D0=B5=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=B2=D1=8B=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=20=D1=81=D0=BE=D0=BD=D0=B0=D1=80=D0=B0=20=D0=BF=D1=80?= =?UTF-8?q?=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 5/5] =?UTF-8?q?=D0=9A=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BD=D0=B0=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=B5=D0=BA=20=D1=81=D0=BE=D0=BD=D0=B0=D1=80=20?= =?UTF-8?q?=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()