Skip to content

Instantly share code, notes, and snippets.

View jechlin-adaptavist's full-sized avatar

Jamie Echlin jechlin-adaptavist

View GitHub Profile
@jechlin-adaptavist
jechlin-adaptavist / ListServiceDeskAccess.groovy
Created April 14, 2020 11:59
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")
ERROR 2020-05-01 10:42:17,084 [com.atlassian.velocity.DefaultVelocityManager] MethodInvocationException occurred getting message body from Velocity: java.lang.ClassCastException: com.sun.jndi.ldap.LdapCtx cannot be cast to org.springframework.ldap.core.DirContextOperations
java.lang.ClassCastException: com.sun.jndi.ldap.LdapCtx cannot be cast to org.springframework.ldap.core.DirContextOperations
at org.springframework.ldap.core.support.AbstractContextMapper.mapFromContext(AbstractContextMapper.java:43)
at org.springframework.ldap.core.LdapTemplate$14.executeWithContext(LdapTemplate.java:899)
at org.springframework.ldap.core.LdapTemplate.executeWithContext(LdapTemplate.java:817)
at org.springframework.ldap.core.LdapTemplate.executeReadOnly(LdapTemplate.java:803)
at org.springframework.ldap.core.LdapTemplate.lookup(LdapTemplate.java:896)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Na
package examples
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def foodField = getFieldById(getFieldChanged())
def subFoodField = getFieldByName('Sub-Food')
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.jql.builder.JqlQueryBuilder
import com.atlassian.jira.util.thread.JiraThreadLocalUtils
def searchService = ComponentAccessor.getComponent(SearchService)
def customFieldManager = ComponentAccessor.customFieldManager
def storyPointsCf = customFieldManager.getCustomFieldObjectByName('Story Points')
def issue = event.issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager
import org.ofbiz.core.entity.DelegatorInterface
import org.ofbiz.core.entity.EntityExpr
import org.ofbiz.core.entity.EntityOperator
def delegatorInterface = ComponentAccessor.getComponent(DelegatorInterface)
def customFieldManager = ComponentAccessor.customFieldManager
def fieldLayoutManager = ComponentAccessor.getComponent(FieldLayoutManager)
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.onresolve.jira.groovy.jql.JqlPagedResultsUtil
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
def jqlPagedResultsUtil = ScriptRunnerImpl.scriptRunner.getBean(JqlPagedResultsUtil)
def authenticationContext = ComponentAccessor.jiraAuthenticationContext
def customFieldManager = ComponentAccessor.customFieldManager
import com.atlassian.greenhopper.model.rapid.RapidView
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.jira.bc.JiraServiceContextImpl
import com.atlassian.jira.bc.filter.SearchRequestService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchRequest
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
@JiraAgileBean
package examples
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin("com.atlassian.servicedesk")
@PluginModule
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
@PluginModule
RequestTypeService requestTypeService
def request = requestTypeService.newQueryBuilder()
.issue(event.issue.id)
.build()
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.FieldManager
import com.atlassian.jira.issue.fields.screen.FieldScreenManager
def fieldScreenManager = ComponentAccessor.getComponent(FieldScreenManager)
def fieldManager = ComponentAccessor.getComponent(FieldManager)
// change to false to remove invalid fields
def preview = true