Skip to content

Commit

Permalink
update Tickets can now call api
Browse files Browse the repository at this point in the history
Signed-off-by: Maxwell Brown <[email protected]>
  • Loading branch information
Galactus22625 committed Nov 11, 2024
1 parent 54f2bf0 commit 87423e9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
9 changes: 4 additions & 5 deletions GenerateCSV.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

InputFields = ["CSV File Name", "Numbr of Issues"]

if __name__ == "__main__":
main()

def main():
csvFields = ["Project Name", "Project Key", "Issue Type", "Status", "Priority", "Issue ID", "Summary", "Comment", "Description", "Project Type"]
issueTypes = ["Story", "Task", "Bug", "Epic"]
Expand Down Expand Up @@ -66,8 +69,4 @@ def processCommandLineArguments():
projectKeys.append(sys.argv[3*project + 3])
numIssues.append(sys.argv[3*project + 4])

return csvName, projectNames, projectKeys, numIssues


if __name__ == "__main__":
main()
return csvName, projectNames, projectKeys, numIssues
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Jira Ticket Scripts.
Generate CSV files with generated Jira Ticket information to import into Jira for volume testing using GenerateCSV.py
Automatically update tickets with UpdateTickets.py
Automatically update tickets with UpdateTickets.py using Jira api.


## Use (UpdateTickets.py)
To run update tickets, add the link to your jira projects rest api url ino the ACCOUNT_URL variable in UpdateTickets.py. Then run with
>python3 UpdateTickets.py --user <jira-username> --password <jira-api-key> --url <url-of-your-jira-site> --projkey [list of project keys]
This will take every ticket in the project and update the description and summary to something new.


## Use (GenerateCSV.py)
In Order to generate CSV File, run
Expand All @@ -14,6 +21,4 @@ To upload generated tickets to Jira, import the generated CSV file.

You may need to use the old Jira UI to upload to multiple projects properly. Do not map Issue ID for the old Jira UI. You may also run into Issues mapping Statuses into projects you already have in Jira if the mapping does not exist. To avoid you can change the statuses fields to ones that match, or just dont map status.

If you want to upload a business project instead of a software project, change the project type category to business. You may also need to alter the possible statuses.

## Use (UpdateTickets.py)
If you want to upload a business project instead of a software project, change the project type category to business. You may also need to alter the possible statuses.
32 changes: 32 additions & 0 deletions UpdateTickets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import requests
import argparse

from GenerateCSV import validProjectKey

API_LINK = "/rest/api/2/"

def main():
args = parseArguments()
auth = (args.user, args.password)
editIssue("ED-1", args.url, auth)
pass

def parseArguments():
parser = argparse.ArgumentParser()
parser.add_argument('--url', type = str, help = "url of your jira site", required = True)
parser.add_argument('--user', type = str, help = "your jira username", required = True)
parser.add_argument('--password', type = str, help = "your jira api key", required = True)
parser.add_argument('--projkey', type = str, nargs='+', help = "project keys that you want updated", required = False)
args = parser.parse_args()
return args
def editIssue(issueKey, url, auth):
apiUrl = url + API_LINK + "issue/" + issueKey

updateJson = {
"fields": {"summary": "What fun"}
}
response = requests.put(apiUrl, json = updateJson, auth = auth)
assert (response.status_code == 200 or response.status_code == 204), f"Expected a response code of 200 or 204. Received a response code of {response.status_code}"

if __name__ == "__main__":
main()

0 comments on commit 87423e9

Please sign in to comment.