// Get the Jira issue manager
def issueManager = ComponentAccessor.getIssueManager()
// Get the Jira issue
def issue = issueManager.getIssueObject(issueKey)
// Create a RemoteIssueLinkBuilder object and set its properties
def remoteLinkBuilder = new RemoteIssueLinkBuilder()
remoteLinkBuilder.url(remoteUrl)
remoteLinkBuilder.title(remoteTitle)
// Create the RemoteIssueLink object
def remoteLink = remoteLinkBuilder.build()
// Add the remote link to the issue
issue.getRemoteIssueLinks().add(remoteLink)
// Save the issue
issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issue, EventDispatchOption.DO_NOT_DISPATCH, false)
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeFacade
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade
@WithPlugin('com.riadalabs.jira.plugins.insight')
@PluginModule ObjectFacade objectFacade
@PluginModule ObjectTypeFacade objectTypeFacade
@PluginModule ObjectTypeAttributeFacade objectTypeAttributeFacade
import com.atlassian.jira.issue.IssueFieldConstants
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
final String fieldName = 'TextField'
// get field by name and hide it
getFieldByName(fieldName).setHidden(true)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
def fieldLayoutItem = ComponentAccessor.getFieldLayoutManager().getFieldLayout(issue).getFieldLayoutItem(field)
def visibility = fieldLayoutItem.getVisibility()
def userUtil = ComponentAccessor.getUserUtil()
def loggedInUser = userUtil.getUserByName(username)
fieldManager.updateCustomField(field.getId(), field.name, field.description, visibility, false, null)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue // Retrieve all issues in Jira def issueManager = ComponentAccessor.issueManager def allIssues = issueManager.getIssueObjects() // Log information about the script execution for each issue allIssues.each { Issue issue -> log.warn("Script triggered for issue: ${issue.key}") log.warn("Script details: Your script details here") }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
def myObject = InsightUtils.getObjectByKey('')
String value = InsightUtils.getAttributeValueFromDotNotation(myObject, "")
//
// Read attributs
//
Map myMap = InsightUtils.getAllAttributesAsKeyValuePairs(myObject)
myMap.each{ attribut, valeur -> log.warn "${attribut} : ${valeur}" }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
def delimiter = ":"
def delimiterIndex = jsmid.indexOf(delimiter)
if (delimiterIndex != -1 && delimiterIndex < jsmid.size() - 1) {
def characterAfterDelimiter = jsmid[delimiterIndex + 1]
println(characterAfterDelimiter) // Output: " "
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate import groovy.json.JsonSlurper // Replace the URL and issue key with your own def url = "https://your-jira-instance.atlassian.net/rest/api/3/issue/ISSUE-KEY" def response = new CustomEndpointDelegate().get(url) // Parse the response as JSON def json = new JsonSlurper().parseText(response.getEntity(String.class)) // Access the fields of the issue def issueKey = json.key def summary = json.fields.summary def description = json.fields.description
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def issueManager = ComponentAccessor.getIssueManager()
// Get the issue using its key
Issue issue = issueManager.getIssueObject("JSM-123")
// Do something with the issue object
if (issue) {
log.debug("Issue summary: ${issue.summary}")
log.debug("Issue description: ${issue.description}")
} else {
log.debug("Could not find issue with key JSM-123")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.atlassian.jira.event.issue.IssueEvent def log = LoggerFactory.getLogger("com.example.listener") def issueEvent = event as IssueEvent def issue = issueEvent.issue def issueKey = issue.key log.debug("Issue ${issueKey} was updated.")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
def issueKey = "" // replace with the key of the issue you want to link to
def url = "" // replace with the URL of the external issue
def title = "" // replace with the title of the external issue
def issueLinkService = ComponentAccessor.getComponent(RemoteIssueLinkService)
def issue = ComponentAccessor.getIssueManager().getIssueObject(issueKey)
def remoteIssueLinkBuilder = new RemoteIssueLinkBuilder()
.issueId(issue.id)
.url(url)
.title(title)
.globalId("")
.applicationName("")
.relationship("")
def remoteIssueLink = remoteIssueLinkBuilder.build()
issueLinkService.createRemoteIssueLink(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issue, remoteIssueLink)
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.
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.plugin.PluginAccessor
import com.atlassian.plugin.Plugin
import com.atlassian.plugin.ModuleDescriptor
@WithPlugin("org.codehaus.groovy.modules.http-builder:http-builder:0.7.1")
def pluginAccessor = ComponentAccessor.getPluginAccessor() as PluginAccessor
def plugin = pluginAccessor.getPlugin("org.codehaus.groovy.modules.http-builder:http-builder")
def moduleDescriptor = plugin.getModuleDescriptor("classpath:groovy/util/XmlSlurper")
if (moduleDescriptor) {
moduleDescriptor.enabled = true
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import groovyx.net.http.HttpBuilder
import com.atlassian.jira.component.ComponentAccessor
// get the base URL of the Jira instance
def jiraBaseUrl = ComponentAccessor.getApplicationProperties().getString("jira.baseurl")
// create an HTTP builder with Basic Authentication using the logged-in user's credentials
def http = new HttpBuilder(jiraBaseUrl)
http.auth.basic(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().name,
ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().password)
// make the API call to the Jira REST API
def response = http.get(path: '/rest/api/2/myself')
assert response.status == 200
def json = new groovy.json.JsonSlurper().parseText(response.getEntity().getContent())
// print the user's display name
println json.displayName
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.