JIRA 本地環境搭建、插件開發、郵件模板定制



系統 Mac 語言 JAVA JIRA 6.4.6 

1、首先安裝本地開發環境,JIRA提供SDK,供本地運行及開發。
 
2、環境搭建好就可以開發插件了。

SDK中 JIRA 版本和 實際使用的JIRA版本比對。以防代碼不可用的情況出現。
插件開發使用的 maven 項目,可通過其中引入的 JIRA 包版本來比對。
這里重點:SDK 中默認引入的是:jira-api 包,可用於web界面開發;功能開發的話,需要放開已注釋的jira-core包。
而 jira-core 包 maven 中央倉庫是不提供的。可在 pom.xml 文件中添加如下配置:
 
<repositories>
        <repository>
            <id>atlassian-public</id>
            <url>https://maven.atlassian.com/repository/public</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
            </snapshots>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>warn</checksumPolicy>
            </releases>
        </repository>
        <repository>
            <id> central</id>
            <name> Maven Repository Switchboard</name>
            <layout> default</layout>
            <url> http://repo1.maven.org/maven2</url>
            <snapshots>
                <enabled> false</enabled>
            </snapshots>
        </repository>
    </repositories>
 
如上導包之后還有問題:jndi 包導入不成功,是因為jndi 的使用需要許可,直接 maven 不可引入。我的處理辦法是,JIRA SDK安裝目錄下有個 repository文件,從中可以找到 jndi 的 jar 包,把這個 jar 包拷貝到項目 maven jar的目錄下,假裝下載下來了。
 

 
該插件 DEMO 文檔對應的是 JIRA 菜單欄的開發。
 
 
以下實踐步驟為workflow中post function開發:
1️⃣不需要輸入參數的 post function:
根據文檔中,插件使用WorkflowNoInputPluginFactory類,然后把原來的父類刪除。插件編譯沒有問題,但是上傳之后出現不可用的情況。
解決辦法:(從網上搜索得,方法不太好,但是解決了辦法)
插件包下創建Factory類,內容為:
public class Factory extends AbstractWorkflowPluginFactory implements WorkflowPluginFactory {
    protected void getVelocityParamsForInput(Map<String, Object> map) {
 
    }
 
    protected void getVelocityParamsForEdit(Map<String, Object> map, AbstractDescriptor abstractDescriptor) {
 
    }
 
    protected void getVelocityParamsForView(Map<String, Object> map, AbstractDescriptor abstractDescriptor) {
 
    }
 
    public Map<String, ?> getDescriptorParams(Map<String, Object> map) {
        return null;
    }
}
2️⃣需要輸入參數的post function:
直接使用生成的 factory類,但是運行時,到輸入參數部分報錯,WorkflowManager類自動注入不成功。問題解決通過文檔: https://bitbucket.org/atlassian/atlassian-spring-scanner/src/1.2.x/README.md?at=1.2.x&fileviewer=file-view-default
主要的部分是在pom.xml 文件中:
找到這部分:
<plugins>
    <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>maven-jira-plugin</artifactId>
修改<Import-Package>中的內容為:
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
com.atlassian.plugin.osgi.bridge.external,
*;resolution:=optional
 
同時需要在 生成的Factory類中類名上加:
構造函數中:
在頭部添加 @Autowired 注解。
即可。

添加自定義的郵件通知
1、添加自定義事件
2、添加自定義郵件模板
 
問題點是:
1、自定義的事件使用自定義的郵件模板。
在:Adding a custom event 步驟中,選擇 Template 時,選擇自定義的模板。
2、自定義的 vm 文件按相同名稱在 html、text、subject分別設置一份。(各文件夾下的格式可參考同文件夾下的其他文件) 
 
 

彈出界面中都會帶有備注框,很雜亂。可以通過配置去除掉。
在字段配置中選取 在彈出框中含有的字段,點編輯,然后在描述中添加如下 js:
<script type="text/javascript">
if(AJS.$('#issue-workflow-transition-submit').val() =='一評會邀'){
AJS.$('div.comment-input').css('display', 'none');
}
</script>
即可。 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM