Skip to content

Commit

Permalink
fix getPIDs commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ovcharenko-di committed Dec 13, 2024
1 parent e00e057 commit 89422b0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ru/pulsar/jenkins/library/utils/CoverageUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ class CoverageUtils {
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()

String pids
def script

if (steps.isUnix()) {
pids = steps.sh("ps -aux | grep '$name' | awk '{print \$2}'", false, true, 'UTF-8')
script = "ps -aux | grep '$name' | grep -v grep | awk '{print \$2}'"
pids = steps.sh(script, false, true, 'UTF-8')
} else {
pids = steps.bat("chcp 65001 > nul \nfor /f \"tokens=2\" %%a in (\"tasklist ^| findstr $name\") do @echo %%a", false, true, 'UTF-8')
script = "@echo off\nchcp 65001 > nul\nfor /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()
}
Expand Down

0 comments on commit 89422b0

Please sign in to comment.