Any chance this is being called from a @NonCPS method? I've seen similar
behaviour in that case.
On Monday, 14 December 2020 at 14:37:55 UTC-8 [email protected] wrote:
> 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 ?
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/3d05598e-01d9-4a86-9b1d-bc798546b94cn%40googlegroups.com.