Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can I link my custom web item (Button) to a Jira Screen?

Dylan Chrispin
May 25, 2021

I have created a custom web item in the form of a button using script fragments.

I require this button when clicked to load a Jira screen that is not set to any of the default actions (Create, Edit or View). 

 

In theory this shouldn't be too hard as the feature described works with workflow transitions however I can not seem to get anything to work or find anything on the internet.

 

Does anybody have a solution that will allow me to link my button to a screen?

 

 

1 answer

Suggest an answer

Log in or Sign up to answer
3 votes
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
November 2, 2019

This will depend on the target system you are trying to connect. They may have different ways of accepting un/pw.

If it's basic authentication then something like this may work:

import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method

def url ="the url of the system your want to connect to: e.g htts://jira.example.com"
def endpoint = "the endpoint path e.g. /rest/2/issue/XXX-123"
def un = "username"
def pw = "password"
def encoded = "$up:$pw".toString().bytes.encodeBase64().toString()
def returnResponse
def httpBuilder = new HTTPBuilder(url)
try{
httpBuilder.request(Method.GET, ContentType.JSON) {
headers."Authorization" = "Basic $encoded"
uri.path = endpoint
response.success = { response, json ->
if (json) {
returnResponse = json
}
}
response.failure = { resp, data ->
if (data) {
returnResponse = [error: "Failed to make http request to $url/$endpoint", statusLine: resp.statusLine, data: data]
} else {
returnResponse = [error: "Failed to make http request to $url/$endpoint", statusLine: resp.statusLine]
}
}
}
} catch(e){
returnResponse = [error: "Some other error occured: $e"]
}
returnResponse
Muthukumaran.G
August 11, 2020

Thank you Peter-Dave. This code helps me a lot. Also i request you that how to pass the parameter in URL like "/rest/gitplugin/1.0/issues/issueId/commits?showFiles=true"

"/commits?showFiles=true"

PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
August 11, 2020

You can either manually add it to the uri.path or apply a the query as a simple map object using uir.query. Like this:

uri.query = [showFiles:true]
TAGS
AUG Leaders

Atlassian Community Events