Jenkins setup:
Jenkins: 2.492.3 OS: Linux - 5.14.0-427.13.1.el9_4.x86_64 Java: 21.0.6 - Eclipse Adoptium (OpenJDK 64-Bit Server VM) --- ant:513.vde9e7b_a_0da_0f antisamy-markup-formatter:173.v680e3a_b_69ff3 apache-httpcomponents-client-4-api:4.5.14-269.vfa_2321039a_83 apache-httpcomponents-client-5-api:5.5-150.veb_76e719855b_ asm-api:9.8-135.vb_2239d08ee90 atlassian-bitbucket-server-integration:4.2.0 authentication-tokens:1.131.v7199556c3004 bootstrap5-api:5.3.3-2 bouncycastle-api:2.30.1.80-261.v00c0e2618ec3 branch-api:2.1217.v43d8b_b_d8b_2c7 build-name-setter:2.5.0 build-timeout:1.38 caffeine-api:3.2.0-166.v72a_6d74b_870f checks-api:370.vb_61a_c57328f3 cloudbees-bitbucket-branch-source:936.3.1 cloudbees-folder:6.1012.v79a_86a_1ea_c1f command-launcher:123.v37cfdc92ef67 commons-compress-api:1.27.1-3 commons-lang3-api:3.17.0-87.v5cf526e63b_8b_ commons-text-api:1.13.1-176.v74d88f22034b_ configuration-as-code:1963.v24e046127a_3f configuration-as-code-groovy:1.1 credentials:1415.v831096eb_5534 credentials-binding:687.v619cb_15e923f dark-theme:524.vd675b_22b_30cb_ display-url-api:2.209.v582ed814ff2f durable-task:587.v84b_877235b_45 echarts-api:5.6.0-4 eddsa-api:0.3.0.1-19.vc432d923e5ee email-ext:1876.v28d8d38315b_d font-awesome-api:6.7.2-1 git:5.7.0 git-client:6.1.3 github:1.43.0 github-api:1.321-488.v9b_c0da_9533f8 github-branch-source:1815.v9152b_2ff7a_1b_ gradle:2.15 gson-api:2.13.1-139.v4569c2ef303f handy-uri-templates-2-api:2.1.8-36.v85e4cb_234a_13 instance-identity:203.v15e81a_1b_7a_38 ionicons-api:88.va_4187cb_eddf1 jackson2-api:2.19.0-404.vb_b_0fd2fea_e10 jakarta-activation-api:2.1.3-2 jakarta-mail-api:2.1.3-2 javax-activation-api:1.2.0-8 javax-mail-api:1.6.2-11 jaxb:2.3.9-133.vb_ec76a_73f706 jdk-tool:83.v417146707a_3d jjwt-api:0.11.5-120.v0268cf544b_89 joda-time-api:2.14.0-127.v7d9da_295a_d51 jquery3-api:3.7.1-3 json-api:20250517-153.vc8a_a_d87c0ce3 json-path-api:2.9.0-148.v22a_7ffe323ce junit:1335.v6b_a_a_e18534e1 ldap:780.vcb_33c9a_e4332 mailer:489.vd4b_25144138f matrix-auth:3.2.6 matrix-project:849.v0cd64ed7e531 metrics:4.2.30-471.v55fa_495f2b_f5 mina-sshd-api-common:2.15.0-161.vb_200831a_c15b_ mina-sshd-api-core:2.15.0-161.vb_200831a_c15b_ okhttp-api:4.11.0-189.v976fa_d3379d6 pam-auth:1.12 pipeline-build-step:567.vea_ce550ece97 pipeline-github-lib:65.v203688e7727e pipeline-graph-analysis:237.v2b_75640ca_888 pipeline-graph-view:538.v647ee88449dd pipeline-groovy-lib:752.vdddedf804e72 pipeline-input-step:517.vf8e782ee645c pipeline-milestone-step:138.v78ca_76831a_43 pipeline-model-api:2.2255.v56a_15e805f12 pipeline-model-definition:2.2255.v56a_15e805f12 pipeline-model-extensions:2.2255.v56a_15e805f12 pipeline-stage-step:322.vecffa_99f371c pipeline-stage-tags-metadata:2.2255.v56a_15e805f12 pipeline-utility-steps:2.19.0 plain-credentials:195.vb_906e9073dee plugin-util-api:6.1.0 prism-api:1.30.0-1 resource-disposer:0.25 scm-api:704.v3ce5c542825a_ script-security:1373.vb_b_4a_a_c26fa_00 snakeyaml-api:2.3-125.v4d77857a_b_402 ssh-credentials:355.v9b_e5b_cde5003 ssh-slaves:3.1031.v72c6b_883b_869 sshd:3.353.v2b_d33c46e970 structs:343.vdcf37b_a_c81d5 templating-engine:2.5.5 theme-manager:294.vf2c2fd783821 timestamper:1.29 token-macro:444.v52de7e9c573d trilead-api:2.209.v0e69b_c43c245 variant:70.va_d9f17f859e0 workflow-aggregator:608.v67378e9d3db_1 workflow-api:1373.v7b_813f10efa_b_ workflow-basic-steps:1079.vce64b_a_929c5a_ workflow-cps:4106.v7a_8a_8176d450 workflow-durable-task-step:1405.v1fcd4a_d00096 workflow-job:1520.v56d65e3b_4566 workflow-multibranch:806.vb_b_688f609ee9 workflow-scm-step:437.v05a_f66b_e5ef8 workflow-step-api:700.v6e45cb_a_5a_a_21 workflow-support:968.v8f17397e87b_8 ws-cleanup:0.48
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') {
//various Jenkins steps and other code
sh "somecommand"
config = readYaml(glob:"file")
}
}
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/
I read the suggested documentation page but my use case is not contemplated.
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.
EDIT:
Cannot provide attachment, new users are unauthorized. I uploaded the file to 5zSfM.zip / download from bashupload.com
Unfortunately, it can be downloaded only once, the lucky first will be able to. Please ask in the comments and I can provide the file in a different way.