Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-29711

Snippet Generator: missing attribute names in single-entry forms

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: pipeline
    • Labels:
      None
    • Environment:
      workflow 1.4..1.8
    • Similar Issues:

      Description

      Using the snippet generator for the HTML publisher, the generated code, yields an exception:

      hudson.AbortException: Cannot publish the report. Target is not specified
      	at htmlpublisher.workflow.PublishHTMLStepExecution.run(PublishHTMLStepExecution.java:64)
      	at htmlpublisher.workflow.PublishHTMLStepExecution.run(PublishHTMLStepExecution.java:43)
      	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousStepExecution.start(AbstractSynchronousStepExecution.java:40)
      

      Follow-up to https://github.com/jenkinsci/htmlpublisher-plugin/pull/15/files#r35805641 ...I suspect a bug in workflow, but probably it has been fixed.

      When a form/class contains only one entry, Snippet Generator provides a code without an attribute name :

      publishHtml([reportName : "", ...])
      

      After that the flow execution calls a constructor with null, because a target is missing. The right call is:

      publishHtml(target: [reportName : "", ...])```
      

      Has this bug been fixed in newer workflow versions? I suspect the answer is "no", but probably I'm doing something wrong in the code

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            I seem to recall something like this affecting ServerEndpointStep/RegistryEndpointStep in docker-workflow: these steps require the parameter name to be specified. The issue here is that there is exactly one (mandatory) parameter, and it is monomorphic. For a polymorphic parameter, this code disambiguates the Map passed by Groovy, deciding whether it is the value of one parameter, or the set of all parameters. Probably that trick just does not work for the monomorphic case, yet Snippetizer assumes that it will. If I am right, either DSL or Snippetizer need to be fixed—preferably the former, so that you can actually use the shorter syntax; but this might be impossible, in which case the latter.

            Show
            jglick Jesse Glick added a comment - I seem to recall something like this affecting ServerEndpointStep / RegistryEndpointStep in docker-workflow : these steps require the parameter name to be specified . The issue here is that there is exactly one (mandatory) parameter, and it is monomorphic. For a polymorphic parameter, this code disambiguates the Map passed by Groovy, deciding whether it is the value of one parameter, or the set of all parameters. Probably that trick just does not work for the monomorphic case, yet Snippetizer assumes that it will. If I am right, either DSL or Snippetizer need to be fixed—preferably the former, so that you can actually use the shorter syntax; but this might be impossible, in which case the latter.
            Hide
            jglick Jesse Glick added a comment -

            Reported to affect properties too.

            Show
            jglick Jesse Glick added a comment - Reported to affect properties too.
            Hide
            abayer Andrew Bayer added a comment -

            PR up at https://github.com/jenkinsci/workflow-cps-plugin/pull/49 - still need to add testing for metasteps with monomorphic single parameters, but I'll get that shortly.

            Show
            abayer Andrew Bayer added a comment - PR up at https://github.com/jenkinsci/workflow-cps-plugin/pull/49 - still need to add testing for metasteps with monomorphic single parameters, but I'll get that shortly.
            Hide
            abayer Andrew Bayer added a comment -

            The issue with properties was similar but not actually the same problem. That was happening because Snippetizer wasn't handling List parameters correctly, failing to put parentheses around the List.

            Anyway - end result, monomorphic single parameters are now handled cleanly in DSL - the syntax that Snippetizer has been generating for that case (i.e., publishHtml([reportName : "", ...]) from the description here) is now valid. And Snippetizer now correctly puts parentheses around List parameters when they're the only argument. Phew.

            Show
            abayer Andrew Bayer added a comment - The issue with properties was similar but not actually the same problem. That was happening because Snippetizer wasn't handling List parameters correctly, failing to put parentheses around the List . Anyway - end result, monomorphic single parameters are now handled cleanly in DSL - the syntax that Snippetizer has been generating for that case (i.e., publishHtml( [reportName : "", ...] ) from the description here) is now valid. And Snippetizer now correctly puts parentheses around List parameters when they're the only argument. Phew.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            src/test/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStepTest.java
            http://jenkins-ci.org/commit/workflow-multibranch-plugin/debde517af80c551a86e17c14f7a6f2eb1ccab83
            Log:
            JENKINS-37477 Working test for snippet generator for triggers.

            Can't do round tripping due to JENKINS-29711, and StepConfigTester
            doesn't work due to this being a Pipeline-specific JobProperty, but
            the snippet generator test does what's expected.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: src/test/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStepTest.java http://jenkins-ci.org/commit/workflow-multibranch-plugin/debde517af80c551a86e17c14f7a6f2eb1ccab83 Log: JENKINS-37477 Working test for snippet generator for triggers. Can't do round tripping due to JENKINS-29711 , and StepConfigTester doesn't work due to this being a Pipeline-specific JobProperty, but the snippet generator test does what's expected.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            src/main/java/org/jenkinsci/plugins/workflow/cps/DSL.java
            src/test/java/org/jenkinsci/plugins/workflow/DSLTest.java
            src/test/java/org/jenkinsci/plugins/workflow/cps/SnippetizerTest.java
            src/test/java/org/jenkinsci/plugins/workflow/testMetaStep/MonomorphicData.java
            src/test/java/org/jenkinsci/plugins/workflow/testMetaStep/MonomorphicStep.java
            http://jenkins-ci.org/commit/workflow-cps-plugin/7857e23bfc9e404063a1e512287a0a735445d318
            Log:
            [FIXED JENKINS-29711] Handle monomorphic single-parameters to steps.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: src/main/java/org/jenkinsci/plugins/workflow/cps/DSL.java src/test/java/org/jenkinsci/plugins/workflow/DSLTest.java src/test/java/org/jenkinsci/plugins/workflow/cps/SnippetizerTest.java src/test/java/org/jenkinsci/plugins/workflow/testMetaStep/MonomorphicData.java src/test/java/org/jenkinsci/plugins/workflow/testMetaStep/MonomorphicStep.java http://jenkins-ci.org/commit/workflow-cps-plugin/7857e23bfc9e404063a1e512287a0a735445d318 Log: [FIXED JENKINS-29711] Handle monomorphic single-parameters to steps.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pom.xml
            http://jenkins-ci.org/commit/workflow-multibranch-plugin/2516ce8009cadc3cd77e66e1932b5c64ae86e3a1
            Log:
            We actually do need workflow-cps 2.14 for JENKINS-29711.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pom.xml http://jenkins-ci.org/commit/workflow-multibranch-plugin/2516ce8009cadc3cd77e66e1932b5c64ae86e3a1 Log: We actually do need workflow-cps 2.14 for JENKINS-29711 .
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            pom.xml
            src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy
            http://jenkins-ci.org/commit/docker-workflow-plugin/3ff3b8bfb06d722bc7f470ccf42b1016eb352fbb
            Log:
            May as well update a bit further and pick up the fix of JENKINS-29711 as well.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy http://jenkins-ci.org/commit/docker-workflow-plugin/3ff3b8bfb06d722bc7f470ccf42b1016eb352fbb Log: May as well update a bit further and pick up the fix of JENKINS-29711 as well.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                oleg_nenashev Oleg Nenashev
              • Votes:
                12 Vote for this issue
                Watchers:
                20 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: