Re: BUG with libraryResource : No such library resource null could be found.

24 views
Skip to first unread message
Message has been deleted

Stuart Rowe

unread,
Dec 17, 2020, 11:58:39 PM12/17/20
to Jenkins Users
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 yannick...@gmail.com 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 ?



Reply all
Reply to author
Forward
Message has been deleted
0 new messages