We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
environment
Given following (simplified) library files in vars directory: testLib.groovy:
def call(body) { pipeline { environment { HI = helper.sayHi() //here helper is null } stages { stage("One") { helper.sayHi() //however here helper is defined echo "${env.HI}" } } } }
helper.groovy:
def sayHi(){ return 'hi' }
And test class:
class DemoTest extends DeclarativePipelineTest { @Override @BeforeEach public void setUp() throws Exception { super.setUp(); } @Test public void demo(){ def lib = loadScript("vars/testLib.groovy") def helper = loadScript("vars/helper.groovy") binding.setVariable("helper", helper) lib.call({}) printCallStack() } }
There is an exception when line HI = helper.sayHi() is executed in environment closure:
java.lang.NullPointerException: Cannot invoke method sayHi() on null object ... at testLib$_call_closure1$_closure2.doCall(testLib.groovy:4) ...
However calling helper.sayHi() at stage level works fine
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Given following (simplified) library files in vars directory:
testLib.groovy:
helper.groovy:
And test class:
There is an exception when line HI = helper.sayHi() is executed in
environment
closure:However calling helper.sayHi() at stage level works fine
The text was updated successfully, but these errors were encountered: