0

I have created a job in Jenkins, for which user provides the value of a specific parameter, let's say PYTHON_PARM, as an input. On this job I execute a python script (using Python Plugin). The problem is that I want to use as a variable the user input $PYTHON_PARM parameter. This is not considered as an environment variable, so when trying to use os.environ['PYTHON_PARM'], this doesn't work. Any idea?

Thanks,

4
  • Can you please provide more detail to add context to the question? Maybe a code snippet or error Commented Jun 22, 2016 at 20:47
  • 1
    Job's slave is a windows pc, so I'm trying through a batch to set the user's input in a variable: Execute Windows batch command: set TYPE = %Type%, Then try to retrieve it in python scipt: Execute Python script: Type = os.environ['TYPE'] The error I'm getting is: Traceback (most recent call last):File "C:\Users\ipsl\AppData\Local\Temp\hudson6045045489072241428.py", line 67, in <module> Type = os.environ['TYPE'] File "C:\Users\ipsl\AppData\Local\Programs\Python\Python35\lib\os.py", line 681, in getitem raise KeyError(key) from None KeyError: 'TYPE' Thanks @minocha Commented Jun 23, 2016 at 9:05
  • Do you use a freestyle job or a Pipeline one? Commented Jun 24, 2016 at 0:57
  • It is a freestyle job. Commented Jun 24, 2016 at 12:13

1 Answer 1

1

Solution: from os import environ

Type = environ['Type']

Sign up to request clarification or add additional context in comments.

1 Comment

Still no answer here?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.