0
我正在使用作業DSL,我想下載文件,讀取它並設置一些env變量。使用作業DSL上的文件功能
def static setSecrets(Job delegate, Map overrides = [:]) {
def liveUsername
def livePassword
def file
new URL('https://path/file').withInputStream { i ->
file.withOutputStream {
it << i
}
}
file.withReader { liveUsername = it.readLines().get(0) }
file.withReader { livePassword = it.readLines().get(1) }
def options = [
IDENTITY_USER: liveUsername,
IDENTITY_PASSWORD: livePassword]
setEnv(delegate, options, overrides)
}
這是I'm接收
java.lang.NullPointerException: Cannot invoke method withOutputStream() on null object
好像文件的不能被使用的功能除外。但在groovy文件中,我期望可以使用Job DSL模板以及所有常規功能。
哪裏是手掌表情圖標,當你需要它! – paul