Hi,
In a shared library, in a groovy script in /vars, the following code is working perfectly:
String call(String stageName) {
String cowMsg = libraryResource 'cow.txt'
if (cowMsg != null) {
def vars = [:]
vars['MESSAGE'] = "BEGIN STAGE: ${stageName}"
def engine = new StreamingTemplateEngine()
def asciiArtMsg = engine.createTemplate(cowMsg).make(vars).toString()
echo "${asciiArtMsg}"
} else {echo "I never see that because cowMsg is not null..."}
This prints my file cow.txt as expected, because cowMsg is NOT null.
BUT : if I remove the "if", I have this error :
No such library resource null could be found.
It is like my resource suddenly became null !
I load some other files without the need of this mysterious "if".
Is that a Groovy bug ?