Created
January 31, 2019 12:23
-
-
Save 01x01/23eedc14c251625f4ae6b26a38b46b3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def attach_file(self,file): | |
with open(file, 'rb') as f: | |
self.jira.add_attachment(issue=self.new_issue, attachment=f,filename="test") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install jira | |
# pipenv install jira | |
from jira import JIRA | |
jira = JIRA(os.getenv("jira_url"),basic_auth=(os.getenv('username'),os.getenv('password'))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def link_issue(self,inwardIssue): | |
res = self.jira.create_issue_link("Related",inwardIssue,self.new_issue) | |
print(res) # <Response [201]> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment