0

I´m using Job DSL and I would like to download a file, read it, and set some env variables.

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) } 

This is the exception that I´m receiving

java.lang.NullPointerException: Cannot invoke method withOutputStream() on null object 

Seems like the features of file cannot being used. But being in groovy file I was expecting can use the Job DSL templates and also, all the groovy features.

1 Answer 1

2

File is null so is throwing NPE when you call a method on it

def file ... file.withOutputStream { // BANG! 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.