It does happen from time to time that developers enter issues with leading or trailing whitespaces. (We're currently on Jira v 3.11)
This is annoying when processing issue data with custom scripts down the pipeline.
Is it possible to validate issue fields for leading / trailing spaces, or to auto-trim all whitespace from (some) issue fields?
Hi Martin,
I do this kind of post processing actions using the Groovy Script Runner Plugin. You can get it from here: https://studio.plugins.atlassian.com/wiki/display/GRV/Script+Runner
You have to follow these steps:
- Install Groovy Script Runner Plugin
- Create a Groovy script file with this content
String trim(String s) {
if (s == null) return null
return s.trim()
}
issue.setSummary(trim(issue.getSummary())) issue.setDescription(trim(issue.getDescription()))
- Add a "Groovy Script Post-Function" _before_ the post function "Create the issue originally" in the transition "Create". (This is the transition that leads in state "Open"). You must enter the full path to your Groovy Script file.
Cheers,
Dieter
Thanks. My, would it be nice if there was something built-in, and I'd not have to manually script yet another thing :-) (Might I ask what Jira Version you're on ... Anything new on this front in JIRA 4 or 5 ?)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Think that should be: issue.getSummary().trim() etc
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes, of course. i had my own method trim to also handle the case issue.getSummary() == null, This method is missing here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Best way to handle that is issue.setSummary(issue.summary?.trim() ?: "")
Which makes me think that you need to be careful with even the most simplest scripts, and test for null values and so on.
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.