jenkinsci / badge-plugin

Jenkins Badge plugin
https://plugins.jenkins.io/badge/
MIT License
32 stars 43 forks source link

Parameters are documented as optional but are not optional #187

Closed MarkEWaite closed 1 month ago

MarkEWaite commented 1 month ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.476 OS: Linux - 6.8.0-40-generic Java: 21.0.4 - Eclipse Adoptium (OpenJDK 64-Bit Server VM) --- PrioritySorter:5.1.0 adoptopenjdk:1.5 analysis-model-api:12.5.0 ant:511.v0a_a_1a_334f41b_ antisamy-markup-formatter:162.v0e6ec0fcfcf6 apache-httpcomponents-client-4-api:4.5.14-208.v438351942757 apache-httpcomponents-client-5-api:5.3.1-117.v4d95117cd34f asm-api:9.7-33.v4d23ef79fcc8 authentication-tokens:1.119.v50285141b_7e1 badge:2.0 basic-branch-build-strategies:81.v05e333931c7d better-pipeline-flowgraph-table:1.5.vd6dfd1f235cb_ bootstrap5-api:5.3.3-1 bouncycastle-api:2.30.1.78.1-248.ve27176eb_46cb_ branch-api:2.1178.v969d9eb_c728e build-blocker-plugin:166.vc82fc20b_a_ed6 build-name-setter:2.4.3 build-timeout:1.33 buildresult-trigger:0.18 caffeine-api:3.1.8-133.v17b_1ff2e0599 checks-api:2.2.1 cloud-stats:336.v788e4055508b_ cloudbees-bitbucket-branch-source:888.v8e6d479a_1730 cloudbees-folder:6.951.v5f91d88d76b_b_ cloudbees-jenkins-advisor:358.v58972d19b_1f0 clover:4.14.2.596.vb_4d6475e990b_ command-launcher:115.vd8b_301cc15d0 commons-compress-api:1.26.1-2 commons-lang3-api:3.17.0-84.vb_b_938040b_078 commons-text-api:1.12.0-129.v99a_50df237f7 conditional-buildstep:1.4.3 config-file-provider:978.v8e85886ffdc4 configuration-as-code:1850.va_a_8c31d3158b_ copyartifact:749.vfb_dca_a_9b_6549 coverage:1.16.1 coverage-badges-extension:47.v41e62ecf0928 credentials:1371.vfee6b_095f0a_3 credentials-binding:681.vf91669a_32e45 dark-theme:479.v661b_1b_911c01 data-tables-api:2.1.6-1 description-setter:239.vd0a_6b_785f92d display-url-api:2.204.vf6fddd8a_8b_e9 docker-commons:443.v921729d5611d docker-java-api:3.3.6-90.ve7c5c7535ddd docker-plugin:1.6.2 docker-workflow:580.vc0c340686b_54 durable-task:577.v2a_8a_4b_7c0247 echarts-api:5.5.1-1 eddsa-api:0.3.0-4.v84c6f0f4969e elastic-axis:464.va_7ed499b_9d75 embeddable-build-status:487.va_0ef04c898a_2 envinject:2.919.v009a_a_1067cd0 envinject-api:1.199.v3ce31253ed13 external-monitor-job:215.v2e88e894db_f8 font-awesome-api:6.6.0-2 forensics-api:2.5.0 git:5.4.1 git-client:6.0.0 git-forensics:2.2.1 git-parameter:0.9.19 git-server:126.v0d945d8d2b_39 gitea:220.v4618c82a_40fb_ github:1.40.0 github-api:1.321-478.vc9ce627ce001 github-branch-source:1797.v86fdb_4d57d43 github-scm-filter-aged-refs:47.v5450b_74d684c github-scm-trait-commit-skip:0.4.0 gitlab-api:5.6.0-97.v6603a_83f8690 gitlab-branch-source:710.v6f19df32544b_ gitlab-plugin:1.9.2 groovy-postbuild:228.vcdb_cf7265066 gson-api:2.11.0-41.v019fcf6125dc h2-api:11.1.4.199-30.v1c64e772f3a_c handy-uri-templates-2-api:2.1.8-30.v7e777411b_148 http_request:1.19 ignore-committer-strategy:1.0.4 implied-labels:342.vf0a_690315013 instance-identity:185.v303dc7c645f9 ionicons-api:74.v93d5eb_813d5f jackson2-api:2.17.0-379.v02de8ec9f64c jakarta-activation-api:2.1.3-1 jakarta-mail-api:2.1.3-1 javadoc:280.v050b_5c849f69 javax-activation-api:1.2.0-7 javax-mail-api:1.6.2-10 jaxb:2.3.9-1 jdk-tool:80.v8a_dee33ed6f0 jersey2-api:2.44-151.v6df377fff741 jira:3.13 jjwt-api:0.11.5-112.ve82dfb_224b_a_d joda-time-api:2.13.0-85.vb_64d1c2921f1 jquery3-api:3.7.1-2 jsch:0.2.16-86.v42e010d9484b_ json-api:20240303-41.v94e11e6de726 json-path-api:2.9.0-58.v62e3e85b_a_655 junit:1300.v03d9d8a_cf1fb_ junit-realtime-test-reporter:149.v05a_d403e2f48 label-verifier:105.vf9d080687b_92 mailer:472.vf7c289a_4b_420 mapdb-api:1.0.9-40.v58107308b_7a_7 markdown-formatter:201.v7057261b_8dff matrix-auth:3.2.2 matrix-project:832.va_66e270d2946 maven-plugin:3.24-rc2456.f85a_3d75535c metrics:4.2.21-451.vd51df8df52ec mina-sshd-api-common:2.13.2-125.v200281b_61d59 mina-sshd-api-core:2.13.2-125.v200281b_61d59 monitoring:1.99.0 naginator:1.481.vcb_b_384a_3de89 nodelabelparameter:1.12.0 okhttp-api:4.11.0-181.v1de5b_83857df parallel-test-executor:512.v751a_b_24e0e67 parameterized-trigger:806.vf6fff3e28c3e pipeline-build-step:540.vb_e8849e1a_b_d8 pipeline-github:2.8-159.09e4403bc62f pipeline-github-lib:61.v629f2cc41d83 pipeline-graph-analysis:216.vfd8b_ece330ca_ pipeline-graph-view:340.v28cecee8b_25f pipeline-groovy-lib:730.ve57b_34648c63 pipeline-input-step:495.ve9c153f6067b_ pipeline-maven:1421.v610fa_b_e2d60e pipeline-maven-api:1421.v610fa_b_e2d60e pipeline-milestone-step:119.vdfdc43fc3b_9a_ pipeline-model-api:2.2214.vb_b_34b_2ea_9b_83 pipeline-model-definition:2.2214.vb_b_34b_2ea_9b_83 pipeline-model-extensions:2.2214.vb_b_34b_2ea_9b_83 pipeline-stage-step:312.v8cd10304c27a_ pipeline-stage-tags-metadata:2.2214.vb_b_34b_2ea_9b_83 pipeline-utility-steps:2.17.0 plain-credentials:183.va_de8f1dd5a_2b_ platformlabeler:2617.v5444054f5e35 plugin-util-api:4.1.0 pollscm:1.5 preSCMbuildstep:71.v1f2990a_37e27 prism-api:1.29.0-17 promoted-builds:965.vcda_c6a_e0998f resource-disposer:0.23 run-condition:1.7 scm-api:696.v778d637b_a_762 script-security:1362.v67dc1f0e1b_b_3 snakeyaml-api:2.3-123.v13484c65210a_ ssh-agent:376.v8933585c69d3 ssh-credentials:343.v884f71d78167 ssh-slaves:2.973.v0fa_8c0dea_f9f sshd:3.330.vc866a_8389b_58 structs:338.v848422169819 support-core:1504.va_1d6d0e4d653 swarm:3.47 testng-plugin:835.v51ed3da_fcc35 text-finder:1.29 theme-manager:262.vc57ee4a_eda_5d throttle-concurrents:2.14 timestamper:1.27 token-macro:400.v35420b_922dcb_ trilead-api:2.147.vb_73cc728a_32e variant:60.v7290fc0eb_b_cd versioncolumn:243.vda_c20eea_a_8a_f view-job-filters:382.vdf2d5e3f02f0 warnings-ng:11.6.0 workflow-aggregator:600.vb_57cdd26fdd7 workflow-api:1336.vee415d95c521 workflow-basic-steps:1058.vcb_fc1e3a_21a_9 workflow-cps:3961.ve48ee2c44a_b_3 workflow-durable-task-step:1371.vb_7cec8f3b_95e workflow-job:1436.vfa_244484591f workflow-multibranch:795.ve0cb_1f45ca_9a_ workflow-scm-step:427.v4ca_6512e7df1 workflow-step-api:678.v3ee58b_469476 workflow-support:920.v59f71ce16f04 ws-cleanup:0.46 xshell:203.v80a_c62d7886f ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Ubuntu 22.04 running a containerized Jenkins controller as described in my docker-lfs repository.

Reproduction steps

  1. Define a Pipeline
    pipeline {
    agent any
    stages {
        stage('Git logo badge') {
            steps {
                addBadge(icon: 'symbol-brands/git plugin-font-awesome-api', text: 'the git logo')
            }
        }
    }
    }
  2. Run the Pipeline and confirm that the console output reports
    WorkflowScript: 6: Missing required parameter: "cssClass" @ line 6, column 17.

Expected Results

Job runs successfully and badge is created on the run

Actual Results

[2024-09-17T01:09:37.719Z] Started by user Mark Waite
[2024-09-17T01:09:37.737Z] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
[2024-09-17T01:09:37.737Z] WorkflowScript: 6: Missing required parameter: "id" @ line 6, column 17.
[2024-09-17T01:09:37.737Z]                    addBadge(icon: 'symbol-brands/git plugin-font-awesome-api', text: 'the git logo')
[2024-09-17T01:09:37.737Z]                    ^
[2024-09-17T01:09:37.737Z] 
[2024-09-17T01:09:37.737Z] WorkflowScript: 6: Missing required parameter: "cssClass" @ line 6, column 17.
[2024-09-17T01:09:37.737Z]                    addBadge(icon: 'symbol-brands/git plugin-font-awesome-api', text: 'the git logo')
[2024-09-17T01:09:37.737Z]                    ^
[2024-09-17T01:09:37.737Z] 
[2024-09-17T01:09:37.737Z] WorkflowScript: 6: Missing required parameter: "style" @ line 6, column 17.
[2024-09-17T01:09:37.737Z]                    addBadge(icon: 'symbol-brands/git plugin-font-awesome-api', text: 'the git logo')
[2024-09-17T01:09:37.737Z]                    ^
[2024-09-17T01:09:37.737Z] 
[2024-09-17T01:09:37.737Z] WorkflowScript: 6: Missing required parameter: "link" @ line 6, column 17.
[2024-09-17T01:09:37.737Z]                    addBadge(icon: 'symbol-brands/git plugin-font-awesome-api', text: 'the git logo')
[2024-09-17T01:09:37.737Z]                    ^
[2024-09-17T01:09:37.737Z] 
[2024-09-17T01:09:37.737Z] 4 errors
[2024-09-17T01:09:37.737Z] 
[2024-09-17T01:09:37.737Z]  at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:309)
[2024-09-17T01:09:37.737Z]  at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1107)
[2024-09-17T01:09:37.737Z]  at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:624)
[2024-09-17T01:09:37.737Z]  at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:602)
[2024-09-17T01:09:37.737Z]  at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:579)
[2024-09-17T01:09:37.737Z]  at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:323)
[2024-09-17T01:09:37.737Z]  at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:293)
[2024-09-17T01:09:37.737Z]  at PluginClassLoader for script-security//org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox$Scope.parse(GroovySandbox.java:163)
[2024-09-17T01:09:37.737Z]  at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:190)
[2024-09-17T01:09:37.737Z]  at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:175)
[2024-09-17T01:09:37.737Z]  at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:652)
[2024-09-17T01:09:37.737Z]  at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:598)
[2024-09-17T01:09:37.738Z]  at PluginClassLoader for workflow-job//org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:335)
[2024-09-17T01:09:37.738Z]  at hudson.model.ResourceController.execute(ResourceController.java:101)
[2024-09-17T01:09:37.738Z]  at hudson.model.Executor.run(Executor.java:445)
[2024-09-17T01:09:37.749Z] [Gitea] do not publish assets due to build being non-Successfully
[2024-09-17T01:09:37.749Z] [withMaven] downstreamPipelineTriggerRunListener - Failure to introspect build steps: java.io.IOException: alpine-pipeline #53 did not yet start
[2024-09-17T01:09:37.749Z] [withMaven] downstreamPipelineTriggerRunListener - Failure to introspect build steps: java.io.IOException: alpine-pipeline #53 did not yet start
[2024-09-17T01:09:37.749Z] Finished: FAILURE

Anything else?

No response

Are you interested in contributing a fix?

Not feasible at this time, focused on Spring Security 6.x Update testing and validation.

jonesbusy commented 1 month ago

I confirm it's a regression from 1.x

[06:00:52.960+02:00] - WorkflowScript: 11: Missing required parameter: "link" @ line 11, column 23.
[06:00:52.960+02:00] -                          addBadge(icon: 'symbol-bug-outline plugin-ionicons-api', text: 'Bug found', color: 'red')
strangelookingnerd commented 1 month ago

I'm on it.

strangelookingnerd commented 1 month ago

I can not reproduce it when using regular pipelines. Could it be that this only applies to declarative pipelines?

jonesbusy commented 1 month ago

Possible that for declarative pipelines structure is validated

I think the solution is to provide a @DataboundConstructor with only mandatory properties and the rest using @DataboundSetter

https://www.jenkins.io/doc/developer/plugin-development/pipeline-integration/#constructor-vs-setters

strangelookingnerd commented 1 month ago

Well, unfortunate setup on my end, I did not check with declarative pipelines... Fix should be available later today, sorry folks.

jonesbusy commented 1 month ago

No problem. Perhaps the plugin deserve such pipeline tests ?

On some plugin I maintain (with pipeline steps) I try to always provide declarative pipeline tests rather than scripted pipeline (example https://github.com/jenkinsci/ansible-plugin/blob/main/src/test/resources/pipelines/minimal.groovy and https://github.com/jenkinsci/ansible-plugin/blob/main/src/test/java/org/jenkinsci/plugins/ansible/PipelineTest.java#L49

They are honnestly easy to write

strangelookingnerd commented 1 month ago

Released in 2.1

MarkEWaite commented 1 month ago

Thanks very much! I've confirmed that it passes my test. I've upgraded it in my environment.