I am trying to run a python script in Jenkins. My Jenkins job is integrated with Jira & on build its gives JIRA_ISSUE_KEY. I want to save the value of JIRA_ISSUE_KEY in a variable.

import subprocess
e = 'echo "$JIRA_ISSUE_KEY"'
x = subprocess.call(e, shell=True)

Whenever I am doing print e it gives o/p as "echo "$JIRA_ISSUE_KEY"" & when I am doing print e its gives o/p as 0.

My overall output in Jenkins console is

JIRA comment is added
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/Jenkins Jira 
Integration Test
[Jenkins Jira Integration Test] $ python /tmp/jenkins2864498002834652992.py
Finished: SUCCESS

I want to save the value MCO-15498 to some variable. How can I do that?

1 Answer 1


using bash script (or pipeline step sh), I would do:

JIRA_ISSUE_KEY=$(python my_python_script.py)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.