Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
ovcharenko-di and coderabbitai[bot] authored Dec 15, 2024
1 parent ad3b37e commit db2f143
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 17 deletions.
9 changes: 8 additions & 1 deletion src/ru/pulsar/jenkins/library/StepExecutor.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 29 additions & 16 deletions src/ru/pulsar/jenkins/library/utils/CoverageUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -87,29 +87,42 @@ 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()) {
Logger.println("Using dbgsPath from config: $dbgsPath")
return dbgsPath.strip()
}

def dbgsFindScript = steps.libraryResource("dbgs.os")
final dbgsFindScriptPath = "build/dbgs.os"
final dbgsPathResult = "build/dbgsPath"
steps.writeFile(dbgsFindScriptPath, dbgsFindScript, 'UTF-8')

steps.cmd("oscript ${dbgsFindScriptPath} ${config.v8version} > ${dbgsPathResult}", false, false)

dbgsPath = steps.readFile(dbgsPathResult).strip()

if (dbgsPath.isEmpty()) {
steps.error("Не удалось найти путь к dbgs")
final dbgsFindScriptPath = "build/tmp/dbgs_${System.currentTimeMillis()}.os"
final dbgsPathResult = "build/tmp/dbgsPath_${System.currentTimeMillis()}"

try {
def dbgsFindScript = steps.libraryResource("dbgs.os")
if (!steps.writeFile(dbgsFindScriptPath, dbgsFindScript, 'UTF-8')) {
throw new IOException("Не удалось записать скрипт поиска dbgs")
}

steps.cmd("oscript ${dbgsFindScriptPath} ${config.v8version} > ${dbgsPathResult}")
dbgsPath = steps.readFile(dbgsPathResult).strip()

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

}

}

0 comments on commit db2f143

Please sign in to comment.