With JIRA JQL I can search for all FixVersions, but I cannot find the projects for unused FixVersions, even they are show in the pulldown list.
Does ScriptRunner support it? Would be great to have the code prepared for usage in the ScriptRunner console.
Reason: There are sometime spelling mistakes, like "Release 1.0 " (a space at the end) and more.
Using the Audit Log I can search for "Project version created" and the version name, but this was not so efficient.
As a search function, no. Because a search is a search for issues, so you'd never find any because the version is not used.
But in the console, you could write a script to get a list of versions from a project, run a short search for any issues for each one, then report on the ones that return 0.
Hey @Jose M_
What Nick said.
So try the following script in your script console
import com.atlassian.jira.component.ComponentAccessor
def versionManager = ComponentAccessor.versionManager
def issueManager = ComponentAccessor.issueManager
def project = ComponentAccessor.projectManager.getProjectObjByKey("TAT")
def fixVersionsInUse = issueManager.getIssueIdsForProject(project.id)?.collect { issueManager.getIssueObject(it) }?.collect {it.fixVersions}?.flatten()
def result = []
result.addAll(versionManager.getVersions(project))
result.removeAll(fixVersionsInUse)
def projectUrl = projectVersionConfigURL(project.key)
"<h3>Verions that are not used as FixVersions for Project $projectUrl </h3> ${result?.join("<br>")}"
static String projectVersionConfigURL (String projectKey) {
def baseUrl = ComponentAccessor.getApplicationProperties().getString("jira.baseurl")
"""
<a href="$baseUrl/plugins/servlet/project-config/$projectKey/administer-versions">$projectKey</a>
"""
}
This is for one project, but you can easily extend it to be for all the projects...
regards, Thanos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot, Thanos! I will try.
Is it also possible to search for all projects in a specific category?
Or can I find out in which project a wrong and empty version, whose name I know, is used? Can I search that wrong version and find the project?
Thanks for any help.
Regards,
José
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you wrap Thanos' code in another loop, then yes.
Use
def projectList = projectManager.getProjectsFromProjectCategory( projectManager.getProjectCategoryObjectByName("My category") )
To get a list of projects to run over, then you can iterate through projectList for each project and run Thanos' code within it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, @Nic Brough -Adaptavist-, but by using
def projectList = projectManager.getProjectsFromProjectCategory( projectManager.getProjectCategoryObjectByName("My category") )
with an existing category I got the message:
Error
No such property: projectManager for class: Script29
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, @Thanos Batagiannis _Adaptavist_, your script works fine!
Just one thing: The result includes the URL ..../plugins/servlet/project-config/.../administer-versions, but at least in our JIRA 7.1.10 the URL is without administer, just /versions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Comment is obsolete.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you created the projectManager like the issueManager and versionManager in Thanos' code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I guess so:
import com.atlassian.jira.component.ComponentAccessor
def versionManager = ComponentAccessor.versionManager
def issueManager = ComponentAccessor.issueManager
def project = ComponentAccessor.projectManager.getProjectObjByKey("...")
def projectList = projectManager.getProjectsFromProjectCategory( projectManager.getProjectCategoryObjectByName("...") )
def fixVersionsInUse = issueManager.getIssueIdsForProject(project.id)?.collect { issueManager.getIssueObject(it) }?.collect {it.fixVersions}?.flatten()
def result = []
result.addAll(versionManager.getVersions(project))
result.removeAll(fixVersionsInUse)
def projectUrl = projectVersionConfigURL(project.key)
"<h3>Verions that are not used as FixVersions for Project $projectUrl </h3> ${result?.join("<br>")}"
static String projectVersionConfigURL (String projectKey) {
def baseUrl = ComponentAccessor.getApplicationProperties().getString("jira.baseurl")
"""
<a href="$baseUrl/plugins/servlet/project-config/$projectKey/administer-versions">$projectKey</a>
"""
}
groovy.lang.MissingPropertyException: No such property: projectManager for class: Script101
at Script101.run(Script101.groovy:6)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There's no projectManager get in there - look at the second line, you need to do the same thing, but create the projectManager object.
Also, you could then, if you felt like it, simplify the def project and projectList lines down.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.