Last active
July 28, 2023 14:40
-
-
Save tdalon/31fbb70b2766342eb54007f93b84121c to your computer and use it in GitHub Desktop.
Jira Quick Set Epic with AutoHotkey
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
Jira_EditEpic(IssueKey, EpicKey:="", EpicLinkCfId:="") { | |
; suc := Jira_EditEpic( IssueKey, EpicKey, EpicLinkCfId:="") | |
JiraRootUrl := Jira_IssueKey2RootUrl(IssueKey) | |
If (EpicLinkCfId ="") { | |
EpicLinkCfId := Jira_GetCfId(JiraRootUrl,"Epic Link") | |
} | |
If (EpicKey ="") { | |
EpicKey := Jira_IssueKey2EpicKey(IssueKey,"",JiraRootUrl) | |
} | |
; https://docs.atlassian.com/software/jira/docs/api/REST/9.4.2/#api/2/issue-editIssue | |
sUrl := JiraRootUrl . "/rest/api/2/issue/" . IssueKey | |
sBody = {"fields": {"%EpicLinkCfId%": "%EpicKey%"}} | |
;sResponse:= Jira_Post(sUrl, sBody) | |
; MsgBox %sUrl%`n%sBody%`n%sResponse% | |
WebRequest := Jira_WebRequest("PUT",sUrl, sBody) | |
suc := (WebRequest.Status = "204") | |
return suc | |
} ; eofun |
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
Jira_IssueKey2EpicKey(IssueKey,sEpicCfName:="",JiraRootUrl:="") { | |
; Select Epic belonging to same project as input IssueKey via ListView GUI | |
If (JiraRootUrl = "") | |
JiraRootUrl := Jira_IssueKey2RootUrl(IssueKey) | |
sJql := "project = " . RegExReplace(IssueKey,"-.*") . " and issuetype = Epic and resolution is EMPTY" | |
sUrl := JiraRootUrl . "/rest/api/2/search?jql=" . sJql | |
sResponse:= Jira_Get(sUrl) | |
;Run %sUrl% | |
Json := Jxon_Load(sResponse) | |
JsonIssues := Json["issues"] | |
If (sEpicCfName ="") | |
sEpicCfName := Jira_GetCfId(JiraRootUrl,"Epic Name") | |
EpicNameArray := [] | |
EpicArray:= {} | |
For i, issue in JsonIssues | |
{ | |
EpicNameArray.Push(issue["fields"][sEpicCfName]) | |
EpicKeyArray.Push(issue["key"]) | |
EpicArray[i,1]:=issue["fields"][sEpicCfName] | |
EpicArray[i,2]:=issue["key"] | |
} | |
;EpicIndex := ListView_Select(EpicNameArray,"Select Epic","Epic Name") | |
EpicIndex := ListView_Select(EpicArray,"Select Epic","Epic Name|Key") | |
EpicKey := JsonIssues[EpicIndex]["key"] | |
return EpicKey | |
} ; eofun |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See details https://tdalon.blogspot.com/2023/07/jira-ahk-set-epic.html