Skip to content

Instantly share code, notes, and snippets.

@01x01
Created January 31, 2019 12:23
Show Gist options
  • Save 01x01/23eedc14c251625f4ae6b26a38b46b3b to your computer and use it in GitHub Desktop.
Save 01x01/23eedc14c251625f4ae6b26a38b46b3b to your computer and use it in GitHub Desktop.
def add_to_current_spring(self):
res = self.jira.sprints(437)
#print(dir(res[0]))
#print(res[0].state)
for sprint in res:
if sprint.state == "ACTIVE":
print(isinstance(sprint.id,int))
print(self.new_issue.key)
res = self.jira.add_issues_to_sprint(sprint_id=sprint.id,issue_keys=[self.new_issue.key])
print(res)
def attach_file(self,file):
with open(file, 'rb') as f:
self.jira.add_attachment(issue=self.new_issue, attachment=f,filename="test")
def close_issue(self):
res = self.jira.transition_issue(self.new_issue,"2891",fields={"assignee":{"name":"+close_folder"},"resolution":{"name":"Completed"}},comment="close the issue")
print(res)
from datetime import datetime,timedelta
import os
def create_issues(project,assignee,summary,description,issuetype,**kw):
issue_dict = {
"project":{"key":project},
"assignee":{"name":assignee},
"summary":summary,
"description":description,
"issuetype":{"name":issuetype},
"customfield_10001": {
"value": "3 - Medium"
},
"customfield_10024": datetime.strftime(datetime.now() + timedelta(days=30),"%Y-%m-%d")
}
if kw:
issue_dict.update(kw)
new_issue = jira.create_issue(fields=issue_dict) # jira is the result of init
print(new_issue) # print issue number but it is issue object
# install jira
# pipenv install jira
from jira import JIRA
jira = JIRA(os.getenv("jira_url"),basic_auth=(os.getenv('username'),os.getenv('password')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment