Skip to content

Instantly share code, notes, and snippets.

@jechlin-adaptavist
Created April 14, 2020 11:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jechlin-adaptavist/e5af9ab86861957c71b49f2b17a043b8 to your computer and use it in GitHub Desktop.
Save jechlin-adaptavist/e5af9ab86861957c71b49f2b17a043b8 to your computer and use it in GitHub Desktop.
Shows security level of all service desks in your instance. For Jira 8.0.0 and above. Execute in Script Console.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.sal.api.ApplicationProperties
import com.atlassian.sal.api.UrlMode
import com.atlassian.servicedesk.api.ServiceDeskService
import com.atlassian.servicedesk.api.util.paging.SimplePagedRequest
import com.onresolve.scriptrunner.canned.util.OutputFormatter
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin("com.atlassian.servicedesk")
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def serviceDeskManager = ComponentAccessor.getOSGiComponentInstanceOfType(ServiceDeskService)
def projectManager = ComponentAccessor.projectManager
def applicationProperties = ComponentAccessor.getOSGiComponentInstanceOfType(ApplicationProperties)
def page = serviceDeskManager.getServiceDesks(user, new SimplePagedRequest(0, 1000))
def baseUrl = applicationProperties.getBaseUrl(UrlMode.ABSOLUTE)
OutputFormatter.markupBuilder {
table(style: 'width: 80%') {
thead {
tr {
td('Service Desk')
td('Project Members Only')
td('Jira Users Only')
td('Anyone')
}
}
tbody {
page.results.each { serviceDesk ->
def accessConfig = serviceDesk.accessConfig
def pkey = projectManager.getProjectObj(serviceDesk.projectId).key
tr {
td {
a(target: '_blank', href: "$baseUrl/servicedesk/admin/${pkey}/request-security", serviceDesk.projectName)
}
td(!accessConfig.openAccess ? '' : '')
td(accessConfig.openAccess && !accessConfig.publicSignUp ? '' : '')
td(accessConfig.publicSignUp ? '' : '')
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment