Hi,
I'm having a few issues getting a Groovy script to execute as a timed job in the Services panel. The script seems to be sound, and will quite happily execute using the script console both as an inline script and as a file from the file system.
I've set the service up as:
Class: com.onresolve.jira.groovy.GroovyService
Name: TestScript
with a schedule of every 15 minutes.
When setting the path, I've tried it as an absolute path from the root, and as a relative path in the scripts folder, both of which work in the script console. The script has a .groovy extension
The logs don't report any errors in finding the files, running the script etc. but at the same time, the issue that is meant to be created by the script isn't created in JIRA.
Is there anything I should be doing to my script in order to make it work differently under the service job? I'm assuming that it's finding the script given the lack of complaining that the file is missing in the logs, but that's just an assumption.
Any help would be greatly appreciated :)
Dave
Hi Aidan,
Thanks for getting back to me, I'm sure I'm missing something stupid but can't see the wood for the trees. The config for the service is:
The overview is:
and the code is:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueInputParameters;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.bc.issue.IssueService;
import com.atlassian.jira.project.Project;
def createIssue(String createdBy, String projKey, String issueSummary, String reportedBy, String issueType = "12345") {
ApplicationUser user = ComponentAccessor.getUserManager().getUserByKey(createdBy);
IssueService issueService = ComponentAccessor.getIssueService();
IssueInputParameters inputParameters = issueService.newIssueInputParameters();
Project curPrj = ComponentAccessor.getProjectManager().getProjectByCurrentKey(projKey)
if(curPrj == null)
return "no project"
inputParameters.setProjectId(curPrj.getId())
.setIssueTypeId(issueType)
.setSummary(issueSummary)
.setReporterId(reportedBy)
.setAssigneeId(curPrj.getLeadUserKey())
IssueService.CreateValidationResult createValidationResult = issueService.validateCreate(user, inputParameters);
if(createValidationResult.isValid()){
IssueService.IssueResult createResult = issueService.create(user, createValidationResult);
if(!createResult.isValid())
return "Error in Issue Creation"
}
else{
return "Not creating invalid issue"
}
}
createIssue("testuser1", "TST", "This is a another test issue", "testuser2");
Hoefully you can spot something I'm missing.
Thanks again
Dave
Hey again Dave!
Sorry for my super belated reply :(
Looking at your script and config, it's hard to get a read on the problem. But I've talked with a colleague and we have a couple of ideas:
ApplicationUser user = ComponentAccessor.getUserManager().getUserByKey(createdBy);aren't working properly. To fix this, look to the community question that I linked above.
log.error("Error in Issue Creation")
Once you've checked these things and have made the appropriate changes, look try running the service again and checking your logs.
Let me know what you find!
Cheers, Aidan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey dave!
Would you mind sharing your service script with me so that I might take a look and see if there are any issues?
Additionally, it may help to see a screenshot or two of your service configuration in JIRA.
Thanks! Aidan
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.