0

I have a script placed in the linux box with name test.py. I have triggered this script using Jenkins and the job is running successfully.

My query here is if i have to stop the script execution, how can i sent the signal to the script to stop from Jenkins itself? I tried stopping the job but that didnt stop the script execution.

Manually from the linux box, I have used the try and except KeyboardInterrupt and it's working. How can i do the same way from the Jenkins. Do i have to add any code to capture this when i stop the Jenkins job. Please clarify.

Sample script -

#!/app/code/Python/bin/python3
import time    
for t in range(0, 500):
        print ("hi")
        time.sleep(5)
sdgd
  • 723
  • 1
  • 17
  • 38
  • why not just shut down jenkins completely? – hypadr1v3 Aug 10 '18 at 07:29
  • how would shutting down jenkins help here? it would stop the execution of other jobs which are already running, right?! – sdgd Aug 10 '18 at 07:37
  • ok if there are other jobs then try this answer https://stackoverflow.com/questions/14456592/how-to-stop-an-unstoppable-zombie-job-on-jenkins-without-restarting-the-server – hypadr1v3 Aug 10 '18 at 07:42
  • i dont think this will stop the execution of my python script which is running on the linux server. The idea here is to stop the python script which is present in the linux server similar to the way it was started using jenkins – sdgd Aug 10 '18 at 08:44
  • do you want to stop it based on some condition using python script? – Talha Junaid Aug 10 '18 at 12:50
  • no condition as such, just stop it when the user wants to end the running script. the reason i am specifying Jenkins is because we give the Jenkins job to a end user and he can start/stop it based on his need. – sdgd Aug 10 '18 at 13:43

0 Answers0