Hello,
In testing with Groovy 3.0.5/JIRA 6.3.6. We have a number of CannedScripts with custom parameters in them that we are testing for en eventual rollout on a production server, but so far we've been unable to get the parameters, and even more recently, the PostFunction, to ''stick'' (or so to speak)
Initially the script was displaying in the postfunction, but no matter what I entered in the fields the data would be discarded and we'd get back the BuiltinScriptErrors that we'd added to validate the entries, essentially telling me that all of the fields were empty. Injecting logs showed that during the doValidate in the script, none of the parameters has values.
I'm experiencing even stranger behavior now, Once the values are submitted in the postfunction parameters, it doesn't even save the script at all, just bring us back to the ''Select Script'' page and it's not even saving the fact that a script was selected.
I upgraded to 3.0.6 with no change. I tried to copy one of the existing builtin scripts and renamed the class and filename, that script is working just fine, eveything is saving properly. I tried to edit that script by changing the parameter names and types by the ones in my custom script, and I got the same behavior in my custom script.
At this point i've simplified my custom script down as much as possible to determine the source of the problem but still no change, there is nothing that I can see that could be causing this problem.
Any help would be appreciated, i'm entering the said test script in its entirety.
Many thanks,
Eric
package com.onresolve.scriptrunner.canned.jira.workflow.postfunctions
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.canned.CannedScript
import com.onresolve.scriptrunner.canned.jira.utils.CannedScriptUtils
import com.onresolve.scriptrunner.canned.jira.utils.WorkflowUtils
import com.onresolve.scriptrunner.canned.util.BuiltinScriptErrors
import com.onresolve.scriptrunner.canned.util.SimpleBuiltinScriptErrors
import groovy.util.logging.Log4j
Log4j
class TestScript2 implements CannedScript {
def projectManager = ComponentAccessor.getProjectManager()
def indexManager = ComponentAccessor.getIssueIndexManager()
public static final String FIELD_LINK_TYPE = 'Parent_Issue_Link_TypeID'
public static final String ISSUE_TYPE = 'IssueType'
public static final String PROJECT = 'project'
String getName() {
return "The Create Task from Approval"
}
public String getHelpUrl() {
return "https://www.google.ca"
}
String getDescription() {
return "Made by ME<br>"
""
}
List getCategories() {
["Function"]
}
List getParameters(Map params) {
[
[
Name: ISSUE_TYPE,
Label: "IssueType",
Type: "list",
Description: """Select the right issue type to create ;""",
Values: CannedScriptUtils.getAllIssueTypes(true)
],
[
Name: FIELD_LINK_TYPE,
Label: "Parent_Issue_Link_TypeID",
Type: "list",
Description: """Please enter the Parent Issue link type that is used.""",
Values: CannedScriptUtils.getAllLinkTypes(true)
],
[
Name: PROJECT,
Label: "Project",
Type: "list",
Description: """Please enter the Project that is used.""",
Values: CannedScriptUtils.getProjectOptions(true)
]
]
}
public BuiltinScriptErrors doValidate(Map params, boolean forPreview) {
BuiltinScriptErrors errorCollection = new SimpleBuiltinScriptErrors()
if (!params[ISSUE_TYPE]) {
errorCollection.addError(ISSUE_TYPE, "You must provide an IssueType.")
}
if (!params[FIELD_LINK_TYPE]) {
errorCollection.addError(FIELD_LINK_TYPE, "You must provide a linktypeID.")
}
if (!params[PROJECT]) {
errorCollection.addError(PROJECT, "You must provide a project.")
}
errorCollection
}
Map doScript(Map params) {
log.warn('Test string')
[:]
}
String getDescription(Map params, boolean forPreview) {
getName()
}
public Boolean isFinalParamsPage(Map params) {
true
}
}