npm-groovy-lint icon indicating copy to clipboard operation
npm-groovy-lint copied to clipboard

Error "unable to resolve class Library" with [email protected]

Open geoffswift opened this issue 1 year ago • 11 comments

Since 15.0.1 we see this error validating our Jenkins script:

Jenkinsfile.groovy
  0     error    Unknown parsing error: "Jenkinsfile.groovy: 1: unable to resolve class Library for annotation\n @ line 1, column 1.\n   @Library('ff-pipeline-lib@LKG') _\n   ^\n"  NglParseError

The problematic line of code looks like this:

  @Library('ff-pipeline-lib@LKG') _

I am using the "recommended-jenkinsfile" configuration.

I tried against these currently available versions:

15.0.0 - Good 15.0.1 - Bad 15.0.2 - Bad

geoffswift avatar Aug 30 '24 07:08 geoffswift

I am also seeing this issue when using the latest code/container image

edwardtew avatar Sep 01 '24 23:09 edwardtew

We are facing the same issue.

dahorak avatar Sep 02 '24 09:09 dahorak

@geoffswift @edwardtew @dahorak Until we find a fix, you can try with --no-parse as workaround

nvuillam avatar Sep 02 '24 09:09 nvuillam

Thanks for your suggestion, we stick to the previous 15.0.0 version as a workaround.

dahorak avatar Sep 02 '24 10:09 dahorak

We have pinned the version at 15.0.0 for now as well. Thanks for the suggestion @nvuillam

edwardtew avatar Sep 11 '24 23:09 edwardtew

We faced the same issue, but using version 15.0.0 served as a workaround for us.

Faisal-Bahoo avatar Sep 12 '24 22:09 Faisal-Bahoo

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

github-actions[bot] avatar Oct 13 '24 00:10 github-actions[bot]

Bump. Don't close please

joshzcold avatar Oct 13 '24 02:10 joshzcold

Same issue, using 15.0.0.

ajs139 avatar Oct 13 '24 02:10 ajs139

Yes, this issue prevents us from using a newer version. Please fix! Thank you!

matt-undo avatar Oct 14 '24 08:10 matt-undo

I know I know... that's hard to find time these days ^^

Anyone is welcome to try bia a PR :)

nvuillam avatar Oct 14 '24 17:10 nvuillam

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

github-actions[bot] avatar Nov 14 '24 00:11 github-actions[bot]

I still would like to see this issue resolved

moni-gomspace avatar Nov 14 '24 07:11 moni-gomspace

Running npm-groovy-lint via https://github.com/super-linter/super-linter bundle which has upgraded it to 15.0.2 yesterday and now we're hitting the below:

    0     error    Unknown parsing error: "/github/workspace/ami_build/Jenkinsfile: 2: unable to resolve class Library for annotation
   @ line 2, column 1.
     @Library('shared-library') _
     ^
  "  NglParseError

yermulnik avatar Nov 18 '24 16:11 yermulnik

Is there any way to disable them via groovylintrc.json?

alexanderbazhenoff avatar Nov 26 '24 00:11 alexanderbazhenoff

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

github-actions[bot] avatar Dec 27 '24 00:12 github-actions[bot]

unstale

yermulnik avatar Dec 27 '24 00:12 yermulnik

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

github-actions[bot] avatar Jan 27 '25 00:01 github-actions[bot]

unstale

moni-gomspace avatar Jan 27 '25 07:01 moni-gomspace

Gonna throw this out there because I get notified about this issue every month, but not about any progress.

https://fvsch.com/stale-bots#:~:text=are%20not%20valued.-,Stale%20bots%20break%20your%20bug%20tracker,3%2C%206%20or%2012%20months.

I really don't like the stale bot.

joshzcold avatar Jan 27 '25 14:01 joshzcold

It seems like the parseError at line 247 in codenarc-factory.js is now a String causing parseError.cause etc to fail.

I added some debug prints to codenarc-factory.js like this:

let msg = parseError.cause && parseError.cause.message ? parseError.cause.message : `Unknown parsing error: ${JSON.stringify(parseError)}`;
console.log(typeof parseError) //Debug log
console.log(parseError) //Debug log

Output of debug prints (anonymized hence the garbage names)

string

/home/user/tkint/src/jenkins_tkint_parking/src/com/vc/tkint/sqa.groovy: 12: unable to resolve class com.vc.tkint.utils.dh
 @ line 12, column 1.
   import com.vc.tkint.utils.dh
   ^

Causing the following error:

 0     error    Unknown parsing error: "/home/user/tkint/src/jenkins_tkint_parking/src/com/vc/tkint//sqa.groovy: 12: unable to resolve class com.vc.tkint.utils.dh\n @ line 12, column 1.\n   import com.vc.tkint.utils.dh\n   ^\n"  NglParseError

Alexandoooor avatar Feb 12 '25 15:02 Alexandoooor

To add to this. This is what the response from codenarc server looks like

Image

About here in the groovy we are expecting parseErrors to be a list of strings https://github.com/nvuillam/npm-groovy-lint/blob/main/groovy/src/main/com/nvuillam/Request.groovy#L149

Which comes out as string from here https://github.com/nvuillam/npm-groovy-lint/blob/main/groovy/src/main/com/nvuillam/Request.groovy#L214

For now I can atleast say that parseFile in v15.0.0 looked different https://github.com/nvuillam/npm-groovy-lint/blob/v15.0.0/groovy/src/main/com/nvuillam/Request.groovy#L214

It used to return a typeof List<Error> which is probably what the frontend codenarc-factory.js is expecting.

Which changed in this PR: https://github.com/nvuillam/npm-groovy-lint/pull/420

joshzcold avatar Feb 21 '25 00:02 joshzcold

@nvuillam I think lots of us in here would appreciate it if we could get this looked at and released as soon as you can.

https://github.com/nvuillam/npm-groovy-lint/pull/444

Thank you ❤️ I appreciate the npm-groovy-lint project.

joshzcold avatar Feb 21 '25 16:02 joshzcold

@joshzcold i understand, but my backlog on many projects is very high, and unfortunately npm-groovy-lint has less business impact for me than the others, especially those i am paid for ... I have to prioritize :/

You are more than welcome to investigate and find a solution before i finally find the time to do so without having to stop sleeping for that ^^

Codenarc released a new version... mayve upgrading npm-groovy-lint with it could help ?

nvuillam avatar Feb 21 '25 20:02 nvuillam

@nvuillam the link in my previous comment is a PR to fix this current issue.

Sorry if I wasn't clear. Just looking for a review

joshzcold avatar Feb 21 '25 21:02 joshzcold

Oh sorry ^^ I look right away :)

nvuillam avatar Feb 21 '25 21:02 nvuillam

@joshzcold you can test with latest @beta version :) (please confirm it works well ^^)

And i have a 5 hours train tomorrow.... I'll make an official release then :)

nvuillam avatar Feb 22 '25 10:02 nvuillam

@nvuillam I tested the new release and I believe we can close this. My jenkins pipelines being linted are getting the correct diagnostics and npm-groovy-lint no longer has issues on Library() or imports

joshzcold avatar Feb 23 '25 21:02 joshzcold

My jenkins pipelines being linted are getting the correct diagnostics and npm-groovy-lint no longer has issues on Library()

+1 confirming no longer seeing issues with Jenkins' Library()

yermulnik avatar Feb 23 '25 21:02 yermulnik

Great, thanks for your fix and your feedback 🥳

nvuillam avatar Feb 24 '25 03:02 nvuillam