插件只需要权限[],其中不包含'execute_java'(JIRA服务器7.1.4)

时间:2016-04-14 10:53:14

标签: java maven plugins jira

我正在尝试将jira的自定义插件,6.3.15升级到7.1.4,但是当我在jira测试环境中上传插件时,则失败并且catalina.out为:

Plugin only requires permission [] which doesn't include 'execute_java',   yet has some java code (classes, libs, spring context, etc), making it un-  loadable.

谷歌搜索我看到:https://docs.atlassian.com/atlassian-plugins-api/4.0.0-m004/atlassian-plugins-api/apidocs/com/atlassian/plugin/Permissions.html#addPermission(com.atlassian.plugin.Plugin,%20java.lang.String,%20com.atlassian.plugin.InstallationMode)

但我不明白如何解决它,任何想法?

插件:

import java.util.Date;

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.event.type.EventType;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.worklog.Worklog;
import com.atlassian.jira.issue.worklog.WorklogImpl;
import com.atlassian.jira.issue.worklog.WorklogManager;

import com.atlassian.jira.event.issue.IssueEventListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AsignedListenerWorklog implements IssueEventListener {

    private static final Logger logger = LoggerFactory.getLogger(AsignedListenerWorklog.class);
    protected WorklogManager worklogManager = ComponentAccessor.getWorklogManager();

    public void workflowEvent(IssueEvent event) {
        if (event.getEventTypeId() != EventType.ISSUE_DELETED_ID) {
            onAssigned(event);
        }
    }
    public boolean isOktoAssign(Issue issue) {
        if (issue.getAssignee() != null) {
            for (Worklog w : worklogManager.getByIssue(issue)) {
                if (w.getUpdateAuthorKey().equals(issue.getAssignee().getName().toLowerCase())) {
                    return false;
                }
            }
            return true;
        }
        logger.error("Issue Assigment null");
        return false;
    }

    public void onAssigned(IssueEvent event) {
        Issue issue = event.getIssue();
        if (isOktoAssign(issue)) {
            WorklogImpl worklog = new WorklogImpl(
                    worklogManager,
                    issue,
                    issue.getId(),
                    issue.getAssignee().getName().toLowerCase(),
                    issue.getSummary(),
                    new Date(),
                    null,
                    null,
                    60L
            );
            logger.info("Add 1m " + worklog.getUpdateAuthor() + " at issue " + issue.getKey());
            worklogManager.create(issue.getAssignee(), worklog, 0L, false);
        }
    }
}

和POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" >
  <modelVersion>4.0.0</modelVersion>
  <groupId>xxx.xxxx</groupId>
  <artifactId>jira-worklog-plugin</artifactId>
  <name>Worklog Plugin</name>
  <version>3.0</version>
  <description>Plugin</description>
    <repositories>
        <repository>
            <id>atlassian</id>
            <url>https://maven.atlassian.com/content/repositories/atlassian-public</url>
        </repository>
        <repository>
            <id>antoher</id>
            <url>https://maven.atlassian.com/content/groups/public</url>
        </repository>
        <repository>
            <id>public</id>
            <url>nexus</url>
        </repository>
    </repositories>
  <dependencies>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-api</artifactId>
            <version>7.1.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-core</artifactId>
            <version>7.1.4</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <distributionManagement>
        <repository>
           <id>releases</id>
            <url>nexus</url>
        </repository>
    </distributionManagement>
</project>

Atlassian的-plugin.xml中:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" >
  <modelVersion>4.0.0</modelVersion>
  <groupId>xxx.xxx</groupId>
  <artifactId>jira-worklog-plugin</artifactId>
  <name>Worklog Plugin</name>
  <version>3.0</version>
  <description>Plugin for update workflow on assigned issue</description>
    <repositories>
        <repository>
            <id>atlassian</id>
            <url>https://maven.atlassian.com/content/repositories/atlassian-public</url>
        </repository>
        <repository>
            <id>antoher</id>
            <url>https://maven.atlassian.com/content/groups/public</url>
        </repository>
        <repository>
            <id>public</id>
            <url>nexus</url>
        </repository>
    </repositories>
  <dependencies>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-api</artifactId>
            <version>7.1.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-core</artifactId>
            <version>7.1.4</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <distributionManagement>
        <repository>
           <id>releases</id>
            <url>nexus</url>
        </repository>
    </distributionManagement>
</project>

1 个答案:

答案 0 :(得分:0)

我改变了Pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" >
  <modelVersion>4.0.0</modelVersion>
  <groupId>xxx.xxx</groupId>
  <artifactId>jira-worklog-plugin</artifactId>
  <name>Worklog Plugin</name>
  <version>3.0</version>
  <description>Plugin for update workflow on assigned issue</description>
    <repositories>
        <repository>
            <id>atlassian</id>
            <url>https://maven.atlassian.com/content/repositories/atlassian-public</url>
        </repository>
        <repository>
            <id>antoher</id>
            <url>https://maven.atlassian.com/content/groups/public</url>
        </repository>
        <repository>
            <id>public</id>
            <url>nexus</url>
        </repository>
    </repositories>
  <dependencies>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-api</artifactId>
            <version>7.1.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-core</artifactId>
            <version>7.1.4</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <distributionManagement>
        <repository>
           <id>releases</id>
            <url>nexus</url>
        </repository>
    </distributionManagement>
</project>

和资源上的atlassian-plugin.xml:

<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
    <plugin-info>
        <description>${project.description}</description>
        <version>${project.version}</version>
        <vendor name="${project.organization.name}" url="${project.organization.url}"/>
        <param name="plugin-icon">images/pluginIcon.png</param>
        <param name="plugin-logo">images/pluginLogo.png</param>
    </plugin-info>

    <!-- add our i18n resource -->
    <resource type="i18n" name="i18n" location="jira-xxx-plugin"/>

    <!-- add our web resources -->
    <web-resource key="jira-xxx-plugin-resources" name="jira-xxx-plugin Web Resources">
        <dependency>com.atlassian.auiplugin:ajs</dependency>
        <resource type="download" name="jira-xxx-plugin.css" location="/css/jira-xxx-plugin.css"/>
        <resource type="download" name="jira-xxx-plugin.js" location="/js/jira-xxx-plugin.js"/>
        <resource type="download" name="images/" location="/images"/>
        <context>jira-xxx-plugin</context>
    </web-resource>

</atlassian-plugin>

它有效!