I need to slightly change the summary on a lot of issues. So I created a workflow with an action to do this and I created the following postfunction script:
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption
IssueManager im = ComponentAccessor.getIssueManager()
MutableIssue currentIssue = im.getIssueObject(issue.key) as MutableIssue
ApplicationUser loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
String summary = issue.getSummary()
String newSummary = ""
log.warn("Summary: "+summary)
if (summary.endsWith("(Alfa)")) {
newSummary = summary.replaceAll("\\(Alfa\\)","(XX)")
log.warn("New summary: "+newSummary)
currentIssue.setSummary(newSummary)
def changedIssue = im.updateIssue(loggedInUser, currentIssue, EventDispatchOption.ISSUE_UPDATED, false)
log.warn("Updated: "+changedIssue.key)
} else {
log.warn("Nothing to do")
}
If you're using a recent version of Scriptrunner to run the scripts, you can use HAPI to simplify the script:
def issue = Issues.getByKey('SR-1') as MutableIssue
issue.set {
setPriority('Highest')
setSummary('my new summary')
}
issue.store()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Michael Madsen and to do some expectation management: I will am not a coder and probably won't solve your problem :)
Have you tried asking chatPBT?
@Rodney Nissen had an interesting article yesterday about that. Check it out and let us know how it went. Of course try the code out in a test environment and all that.
HTH,
KGM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yep, I've seen it asked around 400 Jira questions, including 50 that were coding, it only gave one that wasn't subtly or horribly wrong, and in the code, invented APIs and calls that simply don't exist.
It's not a bad idea, I'd use it, but only after it's been trained on a subject with a decent dataset (and that means "not Stackoverflow" for a lot of subjects, as there's a lot of really bad answers there). It certainly has not been trained on Atlassian stuff yet.
But there are people working on it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.