Hi i need help i need to make a script. I do not have i ide where i make this script.
i need that when i open this link:
http://localhost:8080/rest/scriptrunner/latest/custom/doSomething?issueId=10404&username=User13
i want that jira run a script where it execute a transition. Someone can help me?
i make this script as ScriptRunner Rest Endpoint but it does not work:
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonBuilder
import groovy.transform.BaseScript
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
//import com.atlassian.jira.user.util
@BaseScript CustomEndpointDelegate delegate
doSomething(httpMethod: "GET", groups: ["jira-administrators"]) {
MultivaluedMap queryParams, String body ->
def issueId = queryParams.getFirst("issueId") as String;
def userString = queryParams.getFirst("username") as String;
def issueGet = get('/rest/api/2/issue/' + issueId);
def issueService = ComponentAccessor.getIssueService();
//def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def user = ApplicationUser.getUser(userString);
def issueInputParameters = issueService.newIssueInputParameters();
def transitionValidationResult = issueService.validateTransition(user, issueGet.getId(), 11 as Integer, issueInputParameters);
if (transitionValidationResult?.isValid()) {
issueService.transition(user, transitionValidationResult);
return Response.ok(new JsonBuilder([Risoluzione: "Riuscito"]).toString()).build();
} else return Response.ok(new JsonBuilder([Risoluzione: "Fallito"]).toString()).build();
}
Hi, what do you mean with "it does not work" do you get error messages ? Do you see errors in the Jira log files ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
These are just static type checks. You can ignore them.
Groovy does run time type checking, and this will run correctly.
If you would get rid of these errors, you should declere your variables with the corerct type:
ApplicationUser user = ...
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.