- Berry Kersten
- Feb 13, 2020
- connector-onpremise-jira
- Comment
1 answer
- 210
What about
UNTESTEDdef workflowMap = [ "Open" : "Under Review", "Accepted" : "Under Review", "Done" : "Fixed" ] if (replica.status.name != "Done" || replica.fixVersions != null) { // don't do the status transition when the remote status is 'Done' and the fixVersions is empty Status.receive(useRemoteStatusByDefault = true, workflowMap, [:]) }
- Berry Kersten
Great, thanks.
Unfortunately, it's still doing the transition if the fixVersions is empty. However, I don't see any value for that in the Remote Issues, so it seems to be empty. - Francis Martens (Exalate)
Maybe it is not really empty, but the value is null.
Can you add in your code something like
import com.exalate.api.exception.IssueTrackerException // throw an error to be able to inspect the replicas throw new IssueTrackerException("Fixversion = ${replica.fixVersions}")
This will generate an error. The details of the error contain the message being sent (at bottom of the page)
- Berry Kersten
Yes indeed, that might be the issue. I've added the additional code, and according to the error
Script error for issue RI-4844. Details: javax.script.ScriptException: com.exalate.api.exception.IssueTrackerException: Fixversion = []. Error line: Script178.groovy:35
- Berry Kersten
Getting closer... I tried again using
if (replica.status.name != "Done" && replica.fixVersions.isEmpty()) { Status.receive(useRemoteStatusByDefault = true, workflowMap, [:]) }
But that's not resulting the expected behaviour. I want that (pseudocode)
IF status DONE AND fixVersions has a valueOR IF any other status AND fixVersions is empty
THEN do the workflowmap
As I'm not a Groovy expert, I'm not sure how to do this. Any suggestions?
- Francis Martens (Exalate)
I guess you're almost there - can you try
def workflowMap = [ "Open" : "Under Review", "Accepted" : "Under Review", "Done" : "Fixed" ] if (replica.status.name != "Done" || replica.fixVersions?.size() > 0) { // don't do the status transition when the remote status is 'Done' and the fixVersions is empty Status.receive(useRemoteStatusByDefault = true, workflowMap, [:]) }
- Berry Kersten
Thanks for the new suggestion. However, unfortunately that does not work: when the status is set to Done AND FixVersions is empty, then the sync is performed (including workflowmapping).
I also tried the operator != but that didn't work as well. Even tried == and < (for testing a negative flow).
Just thinking out loud Maybe we should include some kind of other check first, like
def emptyList = fixVersions.isEmpty if (replica.status.name != "Done" || emptyList = false )
- Francis Martens (Exalate)
Yes - this might work - small suggestion ...
if (replica.status.name != "Done" || !replica.fixVersions?.isEmpty) ...
- Berry Kersten
I found out that something else was wrong the config...
The suggestion if (replica.status.name != "Done" || replica.fixVersions?.size() > 0) { works!
CommentAdd your comment...