JIRA插件开发(二)
来源:互联网 发布:淘宝9.9包邮网址 编辑:程序博客网 时间:2024/06/05 07:04
大家都知道,JIRA是一个优秀的问题跟踪系统。
但它不一定就能完全满足你的需要,比如导入Excel方式提交的BUG。
值得庆幸的是,JIRA提供了强大的插件开发功能,现说一说我的一点小经验。
准备: JIRA3.9, JIRA SDK, IDEA / Eclipse, 熟悉Java(废话), 熟悉WebWork
资料: http://confluence.atlassian.com/display/JIRA/JIRA+Development+Hub
官方资料可能无法全部找到你想要的,这时你可以下载一些其它第三方插件来分析其源码。
最重要的一点,那就是反编译JIRA代码,直接查看之。
比如,你想查看 /secure/IssueNavigator.jspa 的代码
打开 WEB-INF/classes/actions.xml 查找 IssueNavigator ,如下:
<action name="issue.IssueNavigator" alias="IssueNavigator">
<view name="success">/secure/views/navigator/navigator.jsp</view>
<view name="error">/secure/views/navigator/navigator.jsp</view>
</action>
<view name="success">/secure/views/navigator/navigator.jsp</view>
<view name="error">/secure/views/navigator/navigator.jsp</view>
</action>
表示其对应的类是 com.atlassian.jira.web.action.issue.IssueNavigator 反编译之即可。
以下说一说一些常用的方法:
JIRA提供各种 xxxManager 提口来实现各种操作
你可以通过 ComponentManager.getInstance().getXxx() 来得到其实例
也可以通过 ComponentManager.getComponentInstanceOfType(xxx.class) 来得到,非常方便。
比如:
JiraAuthenticationContext authenticationContext = ComponentManager.getInstance().getJiraAuthenticationContext();
ProjectComponentManager pcm = (ProjectComponentManager)ComponentManager.getComponentInstanceOfType(ProjectComponentManager.class);
ProjectComponentManager pcm = (ProjectComponentManager)ComponentManager.getComponentInstanceOfType(ProjectComponentManager.class);
例子:
public static User getCurrentUser() {
JiraAuthenticationContext authenticationContext = ComponentManager.getInstance().getJiraAuthenticationContext();
return authenticationContext == null ? null : authenticationContext.getUser();
}
public static Project getProject(long pid) {
return ComponentManager.getInstance().getProjectManager().getProjectObj(pid);
}
public static MutableIssue getIssueById(Long id) {
try {
IssueManager issueManager = ComponentManager.getInstance().getIssueManager();
return issueManager.getIssueObject(id);
} catch (Exception e) {
return null;
}
}
JiraAuthenticationContext authenticationContext = ComponentManager.getInstance().getJiraAuthenticationContext();
return authenticationContext == null ? null : authenticationContext.getUser();
}
public static Project getProject(long pid) {
return ComponentManager.getInstance().getProjectManager().getProjectObj(pid);
}
public static MutableIssue getIssueById(Long id) {
try {
IssueManager issueManager = ComponentManager.getInstance().getIssueManager();
return issueManager.getIssueObject(id);
} catch (Exception e) {
return null;
}
}
把邮件加入JIRA队列:
Email mail = new Email(toaddr);
MailQueueItem item = new SingleMailQueueItem(mail);
ManagerFactory.getMailQueue().addItem(item);
MailQueueItem item = new SingleMailQueueItem(mail);
ManagerFactory.getMailQueue().addItem(item);
另外你可以覆盖JIRA的Action,比如覆盖CreateSubTaskIssueDetails
让其在创建子任务时自动导入父任务的一些数据(如"所属模块")。
<action name="jira.plugin.rstoolkit.webui.action.CreateSubTaskIssueDetails" alias="CreateSubTaskIssueDetails">
<view name="error">/secure/views/createsubtaskissue-details.jsp</view>
<view name="input">/secure/views/createsubtaskissue-details.jsp</view>
<view name="init">/rstoolkit/initsubtaskdetails.jsp</view>
</action>
<view name="error">/secure/views/createsubtaskissue-details.jsp</view>
<view name="input">/secure/views/createsubtaskissue-details.jsp</view>
<view name="init">/rstoolkit/initsubtaskdetails.jsp</view>
</action>
实在不想打字,其它的一些就不一一列举了。
- JIRA插件开发(二)
- Atlassian JIRA 插件开发(二) — 插件项目框架搭建
- Jira 插件开发
- JIRA插件开发
- atlassian JIRA 插件开发(六) — JIRA系统的插件体系,总体一瞥
- jira插件开发数据库配置
- jira插件开发远程调试
- 用JIRA管理你的项目——(二)JIRA语言包支持及插件支持
- 用JIRA管理你的项目——(二)JIRA语言包支持及插件支持
- Atlassian JIRA 插件开发(一) — 环境准备
- Atlassian JIRA 插件开发(三)——常见问题
- Atlassian JIRA 插件开发(四) — 新增 webwork actions
- atlassian JIRA 插件开发(七) — 组成
- atlassian JIRA 插件开发(八) — MVC实现
- Jira插件开发中的附件上传
- atlassian JIRA 插件开发(五) — workflow condition、validator和post functions
- maven插件开发(二)
- jQuery :插件开发(二)
- 使用SetUnhandledExceptionFilter让程序优雅的崩溃
- 侯捷的职业建议(转自阮一峰的网络日志)
- Jira 插件开发
- 使用Python处理Excel表格
- WinCE5.0/6.0下命令行实现自动编译
- JIRA插件开发(二)
- python操作excel
- 系统架构设计
- hp-unix WebLogic 安装笔记
- 毕业后五年拉开差距的原因在哪里???
- python Excel 编程
- Linux下的WebLogic安装部署
- 2010-4-13 pdflush 之 balance_dirty_pages_ratelimited 之ratelimit_pages
- 网络字节序与主机字节序