npm-groovy-lint: Error "unable to resolve class Library" with npm-groovy-lint@15.0.1

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 19
  • Comments: 30 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@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.

@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

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

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 not valued.-,Stale bots break your bug tracker,3%2C 6 or 12 months.

I really don’t like the stale bot.

unstale

I still would like to see this issue resolved

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

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

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

unstale

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.

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

Bump. Don’t close please

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