-
Type:
Bug
-
Resolution: Not A Defect
-
Priority:
Minor
-
Component/s: core
I am trying to migrate all my stages to a shared library so that I can update or add functionality without PRs on project repositories and to propagate changes to all projects that use a specific stage.
The pattern i am trying to use consists of a series of Groovy files under vars:
- pipelineDefinition.groovy contains a "call" function that defines the common structure of the pipelines and takes a config map and a Closure as parameters
- setupStage.groovy containes a "call" function that instantiates an object of class SetupStage (defined under src) and calls its "execute" function.
These are the two main files, from a Jenkinsfile I invoke thet pipelineDefinition function passing a config map and a closure that contains calls to setupStage function and other stages.
pipelineDefinition declares a stage('Startup') with a script step where the closure is called after delegating its calls to the script object.
Now to the issue at hand. Each individual SomethingStage.groovy class under src, defines an execute function structured as follows:
Map execute(Map parameters = [:]) {
  stage('Setup')
}
and it also implements two methods, "propertyMissing" and "methodMissing", to catch calls to methods and properties not defined in the class (like stage, sh etc) and delegate them to script, reference to script is passed to the constructor.
Everything seems to work correctly, aside from some approvals to certain signatures that I had to enable, the only issue is that the logs show a warning for each call that is made to Jenkins steps from inside those execute functions, an example:
expected to call setupStage.invokeMethod but wound up catching sh; see:
https://jenkins.io/redirect/pipeline-cps-method-mismatches/
The issue is not blocking but I would like to know if there is a way to structure my shared libraries so that the warning does not appear.
Attacched is a sample repository with the structure I just described.