JIRA自定义插件开发-创建自定义字段将返回null

赶快

我目前正在开发自定义JIRA插件,但在将插件集成到JIRA项目/问题管理系统时遇到了一些麻烦。我仅使用JIRA SDK已有约4个月的时间,所以我不是专家。

一些注意事项:

  • 我有一个称为PluginListener的类,该类实现InitializingBean。在我的课程中,我将覆盖afterPropertiesSet方法,并将自定义字段代码放在此处。
  • 使用相同的方法,我还创建了一个自定义问题类型,并且我知道这可行,因为我可以在JIRA中使用该问题类型创建问题。
  • 我基本上在这里遵循此指南:http : //www.j-tricks.com/tutorials/plugin-lifecycle-events
  • 我正在使用ATLAS版本:4.2.18

现在,我的代码当前正在发生的情况是createCustomField方法返回null。当我运行atlas-debug命令时,我可以看到(在cmd中)由于该方法而引发了空指针异常。因此未安装该插件。

这是我的代码:

public class PluginListener implements InitializingBean, DisposableBean {

private final IssueTypeManager issueTypeManager;
private final CustomFieldManager customFieldManager;
private final FieldScreenManager fieldScreenManager;

public PluginListener(IssueTypeManager issueTypeManager, CustomFieldManager customFieldManager, FieldScreenManager fieldScreenManager) {
    this.issueTypeManager = issueTypeManager;
    this.customFieldManager = customFieldManager;
    this.fieldScreenManager = fieldScreenManager;
}

@Override
public void destroy() throws Exception {
    // Handle plugin disabling or un-installation here
}

@Override
public void afterPropertiesSet() throws Exception {
    // Handle plugin enabling or installation here      

    // Create issue type:
    IssueType issueType = this.issueTypeManager.createIssueType("TheType", "TheDescription", "/images/icons/issuetypes/genericissue.png");

    // Create custom field:
    // Create a list of issue types for which the custom field needs to be available    
    List<GenericValue> issueTypes = new ArrayList<GenericValue>();
    issueTypes.add(null);

    // Create a list of project contexts for which the custom field needs to be available
    List<JiraContextNode> contexts = new ArrayList<JiraContextNode>();
    contexts.add(GlobalIssueContext.getInstance());

    CustomFieldType fieldType = this.customFieldManager.getCustomFieldType("com.atlassian.jira.plugin.system.customfieldtypes:textfield");        
    CustomFieldSearcher fieldSearcher = this.customFieldManager.getCustomFieldSearcher("com.atlassian.jira.plugin.system.customfieldtypes:textsearcher");

    // Add custom field
    final CustomField cField = this.customFieldManager.createCustomField("FOO", "BAR", fieldType, fieldSearcher, contexts, issueTypes);

    // Add field to default Screen
    FieldScreen defaultScreen = fieldScreenManager.getFieldScreen(FieldScreen.DEFAULT_SCREEN_ID);
    if (!defaultScreen.containsField(cField.getId())) {
        FieldScreenTab firstTab = defaultScreen.getTab(0);
        firstTab.addFieldScreenLayoutItem(cField.getId());
    }
}

}

斯科特·达德利

运行atlas-debug是从JIRA冷启动有效地安装插件。可能的问题是,在JIRA完全准备好操作和处理某些类型的请求之前,已安装JIRA插件(并激活了OSGi捆绑软件)。

要进行调试,请在您的atlas-debug运行失败后,尝试尝试手动导航至Toolgear-> Add-ons-> Manage add-ons,然后尝试重新上传插件.JAR(在target目录中查找)。如果在那个时候能正常工作,则表明JIRA在初始系统启动时根本没有为插件做好准备,因此您需要将字段创建步骤移到其他地方。

您可以尝试onStart事件。如果这对您不起作用,则最可靠的方法可能是延迟初始化,只要您可以确保用户首次访问插件时就执行此步骤。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Wordpress中的自定义新闻通讯插件开发

来自分类Dev

如何使用 Java 开发自定义 Gradle 插件

来自分类Dev

如何自定义Grails字段插件

来自分类Dev

河马自定义必备插件的创建

来自分类Dev

jQuery创建自定义插件CSS

来自分类Dev

在Worklight中创建自定义插件

来自分类Dev

Checkmarx的自定义插件

来自分类Dev

jQuery自定义插件

来自分类Dev

自定义jQuery插件

来自分类Dev

Checkmarx的自定义插件

来自分类Dev

在开发WordPress插件时创建自定义数据库表的最佳选择是什么?

来自分类Dev

API不返回自定义字段

来自分类Dev

Django创建自定义模型字段

来自分类Dev

使用FOSUserBundle创建自定义字段

来自分类Dev

JBilling创建自定义字段

来自分类Dev

自定义字段定义

来自分类Dev

Kong-返回的自定义插件:自定义插件已启用但未安装;

来自分类Dev

通过JIRA REST API从自定义字段获取值

来自分类Dev

反射自定义类型返回null

来自分类Dev

findViewById() 从自定义视图返回 null

来自分类Dev

收集Groovy中的自定义数字字段,并计算返回结果(JIRA脚本运行器)

来自分类Dev

开发流程-WordPress高级自定义字段

来自分类Dev

在安装时使用自定义顺序创建自定义插件joomla

来自分类Dev

Pimcore - 如何通过自定义插件创建自定义表?

来自分类Dev

Flexslider和自定义字段中继器插件

来自分类Dev

Dynamics CRM 2011插件设置自定义字段值

来自分类Dev

从Easy Property Listing Wordpress插件添加自定义字段

来自分类Dev

使图像响应高级自定义字段插件

来自分类Dev

Zabbix自定义报告开发