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
MCO-15498
echo "$JIRA_ISSUE_KEY"
0
Finished: SUCCESS
I want to save the value MCO-15498 to some variable. How can I do that?