0

Due some problems with the hanging of a python process (yandex-tank) during the build process in Jenkins (after which the build could not stop) i need to stop this problematic process with some additional kill command with timeout or using timeout command itself:

timeout $TIMEOUT yandex-tank-jmeter -i -o "jmeter.jmx=$WORKSPACE/$TEST_PLAN"

timeout sends default (15) kill signal, but after that the build goes to status FAILED.

Is there any workaround or special kill signal to make builds successful ?

v0devil
  • 512
  • 1
  • 6
  • 23
  • 1
    What's the reason for yandex-tank to hang? Maybe it's better to solve the problem itself instead of dealing with consequences? – Direvius Oct 28 '15 at 11:04
  • Maybe, but it`s not clear what is going on. I wrote my problem here:http://stackoverflow.com/questions/27419729/jenkinsyandex-tankjmeter-and-hanged-jobs – v0devil Oct 28 '15 at 12:18

2 Answers2

4

Have you tried manual exit code overriding?

timeout $TIMEOUT yandex-tank-jmeter -i -o "jmeter.jmx=$WORKSPACE/$TEST_PLAN"; RES=$?
//If  the  command timed out, then RES equals 124.
...
//at the end of job scenario:
if [ $RES -eq 124 ]; then RES=0;
fi
exit $RES  
Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
r2d2
  • 183
  • 11
0

According to the Jenkins documentation for the "Execute shell" step:

By default, the shell will be invoked with the "-ex" option.

Therefore, Jenkins places all shell code into a shell script file, in the temp directory, something like /tmp/sh/jenkins45723947385985.sh and then executes it as follows:

/bin/sh -xe /tmp/sh/jenkins45723947385985.sh

This can be seen in the console output of the job.

The e option in -xe means that the shell will exit as soon as it has an error. To change this behaviour add a custom shebang line to the start of the Jenkins shell script such as

#!/bin/sh -x

Jenkins will no longer terminate as soon as an error occurs.

user1638152
  • 577
  • 11
  • 23