Answer the question
In order to leave comments, you need to log in
How to define variables in a bash script run by Jenkins?
I have a conditional script that checks for a process on port 8080, writes its id to a variable, and kills by the value of that variable. When run through the standard shell, everything works fine. But when I run this file through jenkins (in the build -> execute shell section I write the full path to the file), then this variable turns out to be empty.
Here is an example script:
#$/bin/sh
for i in 1 2 3 4 5
do
echo "Looping ... number $i"
done
pid="$(/usr/bin/lsof -ti tcp:8080)"
echo $pid
Answer the question
In order to leave comments, you need to log in
first, through jenkins, simply execute
/usr/bin/lsof -ti tcp:8080
make sure that the command returns PID
and then solve it, the command does not work or the variable is not passed
The lsof command doesn't really work; I'll look into that direction, thanks!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question