2017-10-08 78 views
0

Jira中的一個選項是創建自定義字段。在我的工作流中將任務轉換到某個特定狀態時,我想觸發一個groovy腳本,通過REST Post請求將此自定義字段的數據發送到外部php腳本。Jira的附加scriprunner缺少依賴關係嗎?

我使用下面的代碼:

Script2.groovy: 1: unable to resolve class com.atlassian.jira.ComponentAccessor 
@ line 1, column 1. 
    import com.atlassian.jira.ComponentAccessor; 
^

Script2.groovy: 2: unable to resolve class groovyx.net.http.HTTPBuilder 
@ line 2, column 1. 
    import groovyx.net.http.HTTPBuilder; 
^

Script2.groovy: 3: unable to resolve class groovyx.net.http.ContentType 
@ line 3, column 1. 
    import static groovyx.net.http.ContentType.URLENC; 
^

3 errors 

到底哪裏出問題了,而進口的依賴關係:

import com.atlassian.jira.ComponentAccessor; 
import groovyx.net.http.HTTPBuilder; 
import static groovyx.net.http.ContentType.URLENC; 

def customFieldManager = ComponentAccessor.getCustomFieldManager(); 
def email = customFieldManager.getCustomFieldObjectByName('Email Adress'); 

// this is the check 
if(issue.getCustomFieldValue(email)) 
{ 
    def http = new HTTPBuilder('http://www.example.com/Scripts/test.php'); 
    def postBody = [username: 'bob']; // will be url-encoded 

    http.post(path: '/', body: postBody, requestContentType: URLENC) 
    { 
     resp -> println "POST Success: ${resp.statusLine}"; 
     assert resp.statusLine.statusCode == 201; 
    } 
} 
else 
{ 
    //do nothing 
} 

調試/輸出/錯誤控制檯運行的代碼後,列出了以下錯誤?

回答

0

嘗試:

com.atlassian.jira.component.ComponentAccessor

你的包名字似乎不完整。