Passing Values Between SIL and Groovy
Returning Arrays From Groovy
Calls getArchivedVersions() Groovy Script From SIL
function getArchivedVersions() {
string groovyscript = readFromTextFile("Groovy/GetArchivedVersions/getArchivedVersions.groovy");
groovyscript = replace(groovyscript, "$project$", project);
return executeGroovyScript(groovyscript);
}
string [] versions = getArchivedVersions();
for (string version in versions) {
JVersion jVersion = admGetProjectVersion(project, version);
runnerLog("versions " + jVersion);
}
To return the "versions" object as an array, use the join() method:
getArchivedVersions() Groovy Script
def projectKey = "$project$"
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.version.VersionManager
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.version.Version
VersionManager versionManager = ComponentAccessor.getVersionManager()
ProjectManager projectManager = ComponentAccessor.getProjectManager()
Project project = projectManager.getProjectByCurrentKey(projectKey)
def versions=versionManager.getVersionsArchived(project)*.name
return versions.join("|")