Reputation: 2237
I am trying to run a python script on Jenkins
import csv
import time
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
search_term = input("Enter the search (Two Words at most) :")
Is there a way to get this input in Jenkins?
Upvotes: 0
Views: 489
Reputation: 1602
If I'm understanding you correctly you would like your Jenkins pipeline to request input and then passing that input to your python code. I guess then you should remove search_term = input() from your python code and set this as an argument with something like:
parser = argparse.ArgumentParser(description="somedescriptionhere")
parser.add_argument('-s', '--search_term', help="sometexthere", type=str)
args = parser.parse_args()
search_term = args.search_germ
then you can put the following on a step on a jenkins pipeline stage:
input (id: 'userInput', message: 'Enter the search (Two Words at most) :', parameters: [
[$class: 'TextParameterDefinition',
defaultValue: '',
description: 'Some suitable text for your needs',
name: 'search_term']
])
sh(script: "timeout --signal=KILL 600 python3 yourpythoncode.py -s ${search_term}")
That should ask for input on execution and then pass the value to this python execution.
Upvotes: 1