Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Returning Arrays From Groovy

...

Calls getArchivedVersions() Groovy Script From SIL
Code Block
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);
}

Info

To return the "versions" object as an array, use the join() method:

...

getArchivedVersions() Groovy Script
Code Block
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

Warning

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

Example Groovy:

Code Block
return "";