I'm trying to get process id which is running against specific port hence manually following command successfully executed -
lsof -i :9090 -t
But if I run same code on same machine through shell script of Jenkins pipeline, it results into an error - lsof: command not found
Below is code from Jenkins pipeline -
def stopServer() {
script {
echo "Stopping server"
sh '''var=\$(lsof -i :9090 -t)
kill -TERM \$var
'''
}
}
Please help to understand why same command working from same machine's terminal but not from Jenkins pipeline's shell script.