feat: resolve Jenkins shared library methods from @Library annotations and analysis scope#8173
Open
arnabnandy7 wants to merge 1 commit into
Open
feat: resolve Jenkins shared library methods from @Library annotations and analysis scope#8173arnabnandy7 wants to merge 1 commit into
arnabnandy7 wants to merge 1 commit into
Conversation
…s and analysis scope Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's changed?
Implemented type resolution and attribution for Jenkins shared library steps (
vars/*.groovy) in the Groovy parser:GroovyParser.javato index allvars/*.groovyfiles in the input sources.GroovyParserVisitor.javafor@Libraryannotations.GroovyParserVisitor.visitMethodCallExpression, unresolved method calls on implicitthisare resolved and attributed to the identified shared libraries (resolving tojenkins.sharedlibrary.<library_name>.Vars) if they match scope steps or when the@Libraryannotation is present.What's your motivation?
@Libraryannotation in aJenkinsfileare not type-attributed, which causes downstream recipes (likeFindCallGraph) to report "Method type not found" warnings or fail to match.Anything in particular you'd like reviewers to focus on?
collectAnnotationsinGroovyParserVisitor.javawhich recursively traverses statement blocks to capture@Libraryannotations attached to script-level variable/field declarations (e.g.@Library('lib') _).ExecutionContextto pass thesharedLibraryStepsmap collected duringparseInputsdown to theGroovyParserVisitorinstances.Anyone you would like to review specifically?
N/A
Have you considered any alternatives or workarounds?
Considered compiling all files together in a single
CompilationUnit, but that would disrupt the lazy streaming design ofGroovyParser.parseInputsand potentially introduce compilation order/dependency issues. The current design allows files to compile individually while sharing type metadata.Any additional context
N/A
Checklist