-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Исправление ошибки публикации по вложенным папкам в /build/out/allure #141
base: develop
Are you sure you want to change the base?
Changes from 4 commits
b148139
1ef5a0f
038706d
c9d72e9
f2308b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<String> 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 | ||
} | ||
Comment on lines
+95
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Метод |
||
|
||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -52,6 +52,7 @@ class SonarScanner implements Serializable { | |||||||||||||||
} | ||||||||||||||||
} else (branchAnalysisConfiguration == BranchAnalysisConfiguration.AUTO) { | ||||||||||||||||
// no-op | ||||||||||||||||
sonarCommand += "" | ||||||||||||||||
} | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Исправьте синтаксическую ошибку в условии else В текущей реализации присутствует синтаксическая ошибка в условии else. Использование Примените следующие изменения: - } else (branchAnalysisConfiguration == BranchAnalysisConfiguration.AUTO) {
- // no-op
- sonarCommand += ""
+ } else if (branchAnalysisConfiguration == BranchAnalysisConfiguration.AUTO) {
+ // no-op 📝 Committable suggestion
Suggested change
|
||||||||||||||||
|
||||||||||||||||
String projectVersion = computeProjectVersion() | ||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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("../")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Это сильно меняет логику работы этого метода There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. На сейчас эта функция работает не очень корректно. И явно это проблема раз на выходе может впереди быть "../". Функцию надо значительно модифицировать, т.к. она ключевая. getLocalPath(c:\j\workspace\ins-lib_projects_ci_kyporos_main\build\out\allure\bdd) = "../c:/j/workspace/ins-lib_projects_ci_kyporos_main/build/out/allure/bdd" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Меня смущает то, что никто из других пользователей с такой ошибкой не сталкивался. Может проблема в вашей версии дженкинса? Какая у вас? |
||
str = str.substring(3) | ||
} | ||
|
||
return str | ||
} | ||
|
||
static void loadFile(String filePathFrom, def env, String filePathTo) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Класс File использовать нужно использовать очень аккуратно, так как он разрешается на мастере, а не на агенте. Лучше работать через FilePath. Ну и соответственно вынести эту логику в FileUtils
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Груви не знаю. Через нейросеть эту функцию получил и применил, чтобы закрыть проблему.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут не чистый груви, а с ограничениями дженкинса и его распределенной модели выполнения.