Skip to content

Instantly share code, notes, and snippets.

@sebkouba
Created December 13, 2016 13:16
Show Gist options
  • Save sebkouba/64cc08c5793ace5410d80b5935d1d088 to your computer and use it in GitHub Desktop.
Save sebkouba/64cc08c5793ace5410d80b5935d1d088 to your computer and use it in GitHub Desktop.
Batch delete Jira worklogs using Python wrapper
from jira import JIRA
jira = JIRA(server="https://domain.com", basic_auth=('username', 'password'))
# first initial search
query = "timespent > 0 AND project = PROJKEY and issuetype=defect"
relevant_issues = jira.search_issues(query, maxResults=50)
# loop hast to be adjusted if the number of results is very large so the search is executed again
while relevant_issues:
for issue in relevant_issues:
for worklog in jira.worklogs(issue):
print(issue.fields.summary)
print(worklog)
worklog.delete(adjustEstimate="leave")
# if issues remain they are found here
relevant_issues = jira.search_issues(query, maxResults=50)
print("done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment