Wiki

Clone wiki

runner / WebServer

#What's Code Runner Web Server?

Web Server gives you ability to run/read some specific files (see list below) in the server using your browser, for instance:

  • Call Rest WS
  • Create and expose new Rest WS
  • Read log file
  • ...

Binding

The plugin will provide the current $httpServletRequest, $httpServletResponse, $loggedInUser and $log in the script binding. That means you can refer to them using these variables, without declaring them.

Sans titre.png

##Supported extensions |Extensions| |----------| |groovy| |php| |log| |js| |css| |jpg| |jpeg| |gif| |txt| |html, htm|

##Examples

import groovyx.net.http.RESTClient

def RESTClient http
def hostname = "http://localhost:2990"
def auth = 'admin:admin'.bytes.encodeBase64().toString()
http = new RESTClient(hostname)
http.setHeaders([Authorization: "Basic {$auth}"])
def resp = http.get(path: "/jira/rest/api/2/issue/createmeta")

return resp.data.projects[0].name
//callback: http://localhost:2990/jira/plugins/servlet/runnersrv/srv/rest.groovy?issuekey=PR-204

import groovyx.net.http.RESTClient

def RESTClient http
def hostname = "http://localhost:2990"
def auth = 'admin:admin'.bytes.encodeBase64().toString()
http = new RESTClient(hostname)
http.setHeaders([Authorization: "Basic {$auth}"])
def endpoint = "/jira/rest/api/2/issue/"+$httpServletRequest.getParameter("issuekey");
def resp = http.get(path: endpoint)


return resp.data

Updated