Bridge
The bridge is a Javascript library that allows your scripts in the "web panel" feature of ScriptRunner to obtain information about the issue that users are viewing and also to use the Jira REST APIs.
The bridge can be loaded from https://assets.sr-cloud.connect.adaptavistlabs.com/public/js/bridge.js
If a script provides HTML/CSS/JS URLs then the bridge is automatically injected, but it will need to be manually injected for single URL Web Panels.
The bridge serves as a wrapper for the Jira AP module and allows your scripts to communicate with Jira.
Features
The bridge is automatically injected into the page as a global variable, which can be accessed via window.AdaptavistBridge
and window.AdaptavistBridgeContext
.
The AdaptavistBridge
object provides access to the request
property for making HTTP AJAX requests. The AdaptavistBridgeContext
object provides a context
property for obtaining the project and issue keys.
Request
The request
property on AdaptavistBridge
is a function.
This function takes an object as an argument that includes url
and type
properties, plus any of the other options
from Jira’s AP Request options, for example:
requestOptions = {
url: `/rest/api/2/issue/${AdaptavistBridgeContext.context.issueKey}`,
type: 'GET'
};
Note
|
The url property should be a relative url to a Jira REST API and the type property should be one of the following HTTP methods: GET, POST, PUT, DELETE
|
Context
The context
property on AdaptavistBridgeContext
is an object that can have the following possible properties:
{
location,
issueKey,
projectKey
}
Note
|
These properties allow accessing the Jira APIs with these given properties |
Here is an example of what the context
object might contain:
AdaptavistBridgeContext.context = {
projectKey: 'SHOP',
issueKey: 'SHOP-1',
location: 'atl.jira.view.issue.right.context'
};
Example
The bridge will make a request to the Jira REST APIs with an issue key taken from the context object:
AdaptavistBridge.request({
url: `/rest/api/2/issue/${AdaptavistBridgeContext.context.issueKey}`,
type: 'GET'
})
.then(d => {
console.log('data', d)
});
This request will receive all the data for this issue.
Limitations
Users must have correct permissions set in the corresponding applications to view displayed content in the iframes.