I solved the issue with unlabeled Github tickets in the trigger, so that these tickets are not synchronized as long as they do not have a label. The only thing that remains is the point of changing the label/type of an existing issue, I don’t have an idea here yet.
Best regards,
Thorsten
Comments:
Mathieu Lepoutre commented on 18 October 2023
Do you want the issue to change types aswell when you change the github label? If yes, please put the above code outside of the firstSync codeblock.
Thorsten commented on 20 October 2023
Mathieu Lepoutre , I tried it outside the firstSync block but it’s not working:
For Jira. It doesn’t look like you can change issueTypes after creation, we can use jira-automation for it.
Thorsten commented on 27 October 2023
Mathieu Lepoutre ,
thanks for the code. It works to swap the GitHub label when I change the issue type in Jira. (old community)
I’m just wondering why it shouldn’t work the other way around, because it also works without jira-automation in ADO <-> Jira, for example. The statuses are mapped directly here, but in principle this shouldn’t make any difference.
Regards,
Thorsten
Mathieu Lepoutre commented on 21 November 2023
Hi Thorsten
With HttpClient we can change the issueTypes after creation, with Exalate.
Check this code out;
// Gets issueTypes in project
def list = httpClient.get("/rest/api/3/project/${issue.projectKey}")?.issueTypes
def issueTypeIdMap = [:]
for(int i = 0; i < list.size(); i++){
// Create a Type map with right Id's dynamically from rest API, gets every issueType with id from the projectKey
issueTypeIdMap[list?.name[i]] = list?.id[i]
}
def type = replica.customFields."Demo"?.value
String domain = "/rest/api/3/issue/${issue.key}/"
String data = "{\"fields\":{\"issuetype\":{\"id\":${issueTypeIdMap[type]}}}}"
httpClient.put(domain, data)
Now we just have to insert it after the previous code I shared, and then it will work to change issue Types after creation.
I tested your suggestion and it works if the label/issue type is set during creation. But it doesn’t work if I need to change the type/label after the creation. What I didn’t consider on Github is that tickets can be created here without a label and that they will only be given the correct label later. Is there perhaps a way to do this?