diff --git a/src/ru/pulsar/jenkins/library/utils/CoverageUtils.groovy b/src/ru/pulsar/jenkins/library/utils/CoverageUtils.groovy index fd8c5e3d..46acc729 100644 --- a/src/ru/pulsar/jenkins/library/utils/CoverageUtils.groovy +++ b/src/ru/pulsar/jenkins/library/utils/CoverageUtils.groovy @@ -20,7 +20,14 @@ class CoverageUtils { script = "ps -aux | grep '$name' | grep -v grep | awk '{print \$2}'" pids = steps.sh(script, false, true, 'UTF-8') } else { - script = "@echo off\nchcp 65001 > nul\nfor /f \"tokens=2\" %%a in ('tasklist ^| findstr \"$name\" || exit 0') do (@echo %%a)" + script = """@echo off + chcp 65001 > nul + tasklist | findstr "${name}" > nul + if errorlevel 1 ( + exit /b 0 + ) else ( + for /f "tokens=2" %%a in ('tasklist ^| findstr "${name}"') do (@echo %%a) + )""" pids = steps.bat(script, false, true, 'UTF-8') } return pids.split('\r?\n').toList()