簡體   English   中英

groovy.lang.MissingPropertyException:沒有這樣的屬性:類的腳本:groovy.lang.Binding

[英]groovy.lang.MissingPropertyException: No such property: script for class: groovy.lang.Binding

我正在嘗試使用 Jenkinsfile(groovy 腳本)獲取提交者的電子郵件地址

我使用了這里批准的這個解決方案: https : //stackoverflow.com/a/46648279/10899655

我的代碼:

@Library('shared-libraries') _ 
pipeline{
  //my stages here

}
post { 
    always { 
        script { 
            def changeSet = script.currentBuild.changeSets[0]; 
            Set authors = []; 
            if (changeSet != null) { 
                for (change in changeSet.items) { 
                    authors.add(GetUserEmail{user=change.author}) 
                } 
            } 
        } 
    } 
}

但是我收到此錯誤消息:

Error when executing always post condition:
groovy.lang.MissingPropertyException: No such property: script for class: groovy.lang.Binding

我該如何解決?

先感謝您

您沒有在行中定義script變量

def changeSet = script.currentBuild.changeSets[0]; 

您需要先定義它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM