我想讀Groovy Postbuild步驟中的環境變量。我能夠讀取傳遞給構建的參數的值,但無法讀取在我的Execute Windows batch command
之一中設置的參數的值。詹金斯 - 如何閱讀groovy後構建步驟中的環境變量
在我Execute Windows batch command
的一個例子,我這樣做:
SET custom_param=myValue
,如果我在其他詹金斯步驟/作業使用${custom_param}
,它得到我的價值。所以我相信它有價值。我不能在Groovy腳本得到它
我曾嘗試以下這樣做,他們都沒有工作:
- manager.envVars [ 'CUSTOM_PARAM']
- build.buildVariableResolver.resolve ( 'CUSTOM_PARAM')
- build.getEnvironment(聽衆)獲得( 'CUSTOM_PARAM')
這裏的任何幫助將是巨大
您正在執行「groovy腳本」還是「系統groovy腳本」?顯然,groove腳本無法訪問環境變量。更多這裏:http://stackoverflow.com/questions/21236268/access-to-build-environment-variables-from-a-groovy-script-in-a-jenkins-build-st – hakamairi
嘗試在另一批次中回顯它,它通常不起作用。檢查EnvInject插件是否可以提供幫助。 –