pythonpython-2.7jenkinsfabric

How to read fabric(python) confirmation in jenkins job execution


We have a python deployment script for our application and we use fabric package to ask user for the confirmation to proceed further (if user fixes manually or want to ignore) with any issues during the deployment.

question="Failure encountered during deployment.Would you like to continue?"
if confirm(question):
   logging.info("User request to continue...")
   pass
else:
   sys.exit(1)

We are able to successfully read/capture the user input when we execute the python script from a linux machine.

However, when we are executing the same script from Jenkins job execute shell its not asking/waiting for the user input when there is a failure to proceed further or not and throwing the following EOF error and exiting the deployment program in middle.

Error: if confirm(question): File "/usr/local/lib64/python2.7/site-packages/fabric/contrib/console.py", line 27, in confirm response = prompt("%s [%s] " % (question, suffix)).lower() File "/usr/local/lib64/python2.7/site-packages/fabric/operations.py", line 211, in prompt value = raw_input(prompt_str) or default EOFError: EOF when reading a line

Is there a way to pause the Jenkins job execution during the fabric confirmation question and give chance to user to enter/input something to the Jenkins job execution? if so, how to achieve/implement that process ?


Solution

  • we couldn't solve this due to Jenkins doesn't have a feature to wait for user input except in the pipeline jobs