Hi,
I am trying to create a script which compare multi line text to some custom field text:
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Fix Description")
def effortText = issue.getCustomFieldValue(field)
def originalText = """\
Please use this checklist to provide relevant information:
1. Describe fix both at product level and technical level.
2. Validation guidelines –provide precise instructions (preferable at product level).
3. In validation instructions also consider regression guidelines (affected areas). What customer use cases should be tested due to the fix
"""
log.setLevel(org.apache.log4j.Level.DEBUG)
log.debug("${effortText}")
log.debug("${originalText}")
if (effortText == originalText){
return 1
}
At the Logs tab I get that effortText = originalText ,but at the result tab its not returning 1 , just null.
Please help
How do you conclude "... At the Logs tab I get that effortText = originalText..." ? Just by visual inspection ? That might miss differences in spaces, end-of-lines, ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
...so probably the texts are not exactly the same... ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
They are the same, I used copy paste and preformed double check for difference in space etc... its something else that is missing in my code..
This is what I get at "Logs" tab (When I used another text):
2019-05-07 00:36:01,536 DEBUG [customfield.GroovyCustomField]: Please use this checklist to provide relevant information
Describe fix both at product level and technical level.
2019-05-07 00:36:01,537 DEBUG [customfield.GroovyCustomField]: Please use this checklist to provide relevant information
Describe fix both at product level and technical level.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you add some logging in the If (effortText == originalText){0 construction to check if according groovy both texts are identical (in stead of logging both textxs and do manual validation).
If they are not identical for groovy, you should investigate why...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Wired, when I added logging inside the "if" it dosent return anything at the log.
is that what you meant?:
if (effortText == originalText){
log.debug("bla bla")
return 1
}
I forget to mention that if the text is one line, my code works well.. so its have to be something with "multi line"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, if you don't see anything in the logging, this means that both texts are different for groovy.
Can you validate (log) the classes of both texts ? (effortText.getClass())
Your effortText is probably another type than just String or GString...
Can you write your test as
if (effortText.toString() == originalText){
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The class are identical:
2019-05-07 02:52:34,338 DEBUG [customfield.GroovyCustomField]: class java.lang.String 2019-05-07 02:52:34,338 DEBUG [customfield.GroovyCustomField]: class java.lang.String
And I tried the
if (effortText.toString() == originalText){
return 1
}
Still getting null result.. :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So for groovy both strings are somewhere different...
Maybe start with a VERY simple example...
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.