I have created a custom plugin called "MyTimesheet" to generate various timesheet report. I have installed the plugin in Jira.
I want to create a groovy script which will send the report, generated by MyTimesheet plugin, via Email.
For that, I need to import the class from MyTimesheet plugin, which will return the HTML object of the report.
MyTimesheet plugin has package "package com.atlassian.tutorial.mytimesheet" and in that there is a class called "timesheetclass". There is a method called "generateReport()" in class timesheetclass.
When I try to import "com.atlassian.tutorial.mytimesheet" or "com.atlassian.tutorial.mytimesheet.timesheetclass", it throws below error.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script19.groovy: 1: unable to resolve class com.atlassian.tutorial.mytimesheet@ line 1, column 1. import com.atlassian.tutorial.helloworld; ^ 1 error
Can you please help me with this. How can I use the method from my custom plugin's class?
Community moderators have prevented the ability to post new answers.
Found alternate solution to send email. "Scheduling Events via SAL"
Try adding the class to a component module in your plugin , refer this document https://developer.atlassian.com/display/JIRADEV/Component+Plugin+Module
Most probably this should solve the unable to resolve class exception
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I already have this in my plugin. I have pasted code below from two files.
Code from atlassian-plugin.xml
<component key="TimesheetClass" class="com.atlassian.tutorial.mytimesheet.timesheetclassImpl" public="true">
<interface>com.atlassian.tutorial.mytimesheet.timesheetclass</interface> </component>
Code from timesheetclassImpl.java
package com.atlassian.tutorial.mytimesheet; import com.atlassian.sal.api.ApplicationProperties; public class timesheetclassImpl implements timesheetclass { private final ApplicationProperties applicationProperties; public timesheetclassImpl (ApplicationProperties applicationProperties) { this.applicationProperties = applicationProperties; } public String GenerateReport() { return "Report is generated."; } }
---------------------------------------------------
Now how can I use GenerateReport() method in Groovy script?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you should be able to use ComponentAccessor.getComponent(your class), but you might need to import it in script runner's pom, which you don't want to do.
Also see https://answers.atlassian.com/questions/73449/using-the-greenhopper-api-to-modify-rank?page=1#73622 - which is an answer for greenhopper, but is basically the sme problem you have.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh sorry I have modified the class name in error message. Error is : org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script19.groovy: 1: unable to resolve class com.atlassian.tutorial.mytimesheet@ line 1, column 1. import com.atlassian.tutorial.mytimesheet; ^ 1 error I am not sure about plugin version but I have created plugin with SDK 4.1.4 and JIRA 5. Is this a helpful? |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh sorry I have modified the class name in error message. Error is :
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script19.groovy: 1: unable to resolve class com.atlassian.tutorial.mytimesheet@ line 1, column 1. import com.atlassian.tutorial.mytimesheet; ^ 1 error
I am not sure about plugin version but I have created plugin with SDK 4.1.4 and JIRA 5. Is this a helpful?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For a start why does the error message refer to helloworld?
Is your plugin plugins2?
You may need to make a public component module for your plugin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.