1
0
mirror of https://github.com/firstBitMarksistskaya/jenkins-lib.git synced 2025-08-25 20:09:25 +02:00

Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Dima Ovcharenko
2024-12-15 15:51:32 +03:00
committed by GitHub
parent ad3b37e840
commit db2f14381b
2 changed files with 34 additions and 14 deletions

View File

@@ -77,7 +77,14 @@ class StepExecutor implements IStepExecutor {
@Override
void start(String executable, String params) {
steps.start(executable, params)
if (executable == null || executable.trim().isEmpty()) {
throw new IllegalArgumentException("executable не может быть пустым")
}
try {
steps.start(executable, params)
} catch (Exception e) {
throw new RuntimeException("Ошибка при запуске процесса: ${e.message}", e)
}
}
@Override

View File

@@ -17,7 +17,7 @@ class CoverageUtils {
def script
if (steps.isUnix()) {
script = "ps -aux | grep '$name' | grep -v grep | awk '{print \$2}'"
script = "ps -C '$name' -o pid="
pids = steps.sh(script, false, true, 'UTF-8')
} else {
script = """@echo off
@@ -87,6 +87,9 @@ class CoverageUtils {
}
static String findDbgs(IStepExecutor steps, JobConfiguration config) {
if (steps == null || config == null) {
throw new IllegalArgumentException("Некорректные параметры поиска dbgs")
}
String dbgsPath = config.coverageOptions.dbgsPath
if (!dbgsPath.isEmpty()) {
@@ -94,22 +97,32 @@ class CoverageUtils {
return dbgsPath.strip()
}
def dbgsFindScript = steps.libraryResource("dbgs.os")
final dbgsFindScriptPath = "build/dbgs.os"
final dbgsPathResult = "build/dbgsPath"
steps.writeFile(dbgsFindScriptPath, dbgsFindScript, 'UTF-8')
final dbgsFindScriptPath = "build/tmp/dbgs_${System.currentTimeMillis()}.os"
final dbgsPathResult = "build/tmp/dbgsPath_${System.currentTimeMillis()}"
steps.cmd("oscript ${dbgsFindScriptPath} ${config.v8version} > ${dbgsPathResult}", false, false)
try {
def dbgsFindScript = steps.libraryResource("dbgs.os")
if (!steps.writeFile(dbgsFindScriptPath, dbgsFindScript, 'UTF-8')) {
throw new IOException("Не удалось записать скрипт поиска dbgs")
}
dbgsPath = steps.readFile(dbgsPathResult).strip()
steps.cmd("oscript ${dbgsFindScriptPath} ${config.v8version} > ${dbgsPathResult}")
dbgsPath = steps.readFile(dbgsPathResult).strip()
if (dbgsPath.isEmpty()) {
steps.error("Не удалось найти путь к dbgs")
if (dbgsPath.isEmpty()) {
steps.error("Не удалось найти путь к dbgs")
}
Logger.println("Found dbgs: ${dbgsPath}")
return dbgsPath
} finally {
try {
steps.deleteFile(dbgsFindScriptPath)
steps.deleteFile(dbgsPathResult)
} catch (Exception e) {
Logger.println("Не удалось удалить временные файлы: ${e.message}")
}
}
Logger.println("Found dbgs: ${dbgsPath}")
return dbgsPath
}
}