Skip to end of banner
Go to start of banner

Passing Values Between SIL and Groovy

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Current »

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("|") 

Returning Null Values From Groovy

SIL does not accept null values. Never end a Groovy script with "return;". Return empty strings instead.

Example Groovy:

return "";
  • No labels