I have the following code that instantiates a JIRA instance and ultimately pulls issues from it and writes to Excel. When I do it all within the python script as below, it works fine:
jql_string = 'project = xyz AND assignee in (larry, curly, moe) ORDER BY key DESC'
fields = "Key, Summary, Assignee, Created, Updated)"
# Instantiate the Jira instance
jira = JIRA(server="https://myserver.mycompany.com/",
token_auth="abcd1234") # JIRA Personal access token
# Write the issues to a dictionary
for issues in jira.search_issues(jql_str=jql_string,fields=fields,startAt=0, maxResults=False):
issue = jira.issue(issues.key)
issueList.append(
{'Issue Type' : issue.fields.issuetype,
'Issue key' : issue.key,
'Issue id' : issue.id,
'Summary' : issue.fields.summary,
'Assignee' : issue.fields.assignee,
'Updated' : issue.fields.updated,
'Severity' : issue.fields.customfield_12825
}
# Write out data frame
.....
However, when I try to import jql_string, token, and server from an .env file (I want to create an executable to pass for others to use), like:
# Get environment variables
jql_string = os.environ.get('JQL_STRING')
token = os.environ.get('JIRA_USER_TOKEN')
server = os.environ.get('JIRA_SERVER')
and pass through code as shown above...
I can debug and see the environment variables are imported correctly, but passing it through the code above (with the variables replacing the hardcoded values) I get authoriation and timeout issues. I can’t figure out what I’m doing wrong. I’ve tried to do them one by one (e.g., hardcoding token and jql string and just having server as an environment variable, but then JIRA times out).
3