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

Integer and decimal step parameters are save as string in Pipeline Editor

    • 1.0

      When editing a step with an integer parameter (for example Sleep), the saved value for this parameter is a string, and this make the resulting pipeline failing.

      Here is an sample of what is generated by the pipeline editor

      sleep(time: '5', unit: 'MINUTES')
      

      and what is should have been

      sleep(time: 5, unit: 'MINUTES')
      

       

          [JENKINS-42640] Integer and decimal step parameters are save as string in Pipeline Editor

          I think I tracked where the issue is, and I've submitted this pull request to fix it : https://github.com/jenkinsci/blueocean-pipeline-editor-plugin/pull/30

          jeremie violas added a comment - I think I tracked where the issue is, and I've submitted this pull request to fix it :  https://github.com/jenkinsci/blueocean-pipeline-editor-plugin/pull/30

          James Dumay added a comment -

          Thanks for the contribution jviolas

          James Dumay added a comment - Thanks for the contribution jviolas

          Code changed in jenkins
          User: Jeremie Violas
          Path:
          src/main/js/components/properties/DecimalPropertyInput.jsx
          src/main/js/components/properties/IntegerPropertyInput.jsx
          http://jenkins-ci.org/commit/blueocean-pipeline-editor-plugin/e0a0d5c3cee8fbe6f79d449570df8de92bddb4b7
          Log:
          JENKINS-42640: Parse the value of the input of integer and decimal parameter before setting it in step data. (#30)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jeremie Violas Path: src/main/js/components/properties/DecimalPropertyInput.jsx src/main/js/components/properties/IntegerPropertyInput.jsx http://jenkins-ci.org/commit/blueocean-pipeline-editor-plugin/e0a0d5c3cee8fbe6f79d449570df8de92bddb4b7 Log: JENKINS-42640 : Parse the value of the input of integer and decimal parameter before setting it in step data. (#30)

          Andrew Bayer added a comment -

          Andrew Bayer added a comment - Declarative PR up for this (and JENKINS-42551 ) at  https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/133

          James Dumay added a comment -

          Thanks a lot abayer - appreciate the fast turn around

          James Dumay added a comment - Thanks a lot abayer - appreciate the fast turn around

          James Dumay added a comment -

          Thanks again

          James Dumay added a comment - Thanks again

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/DescriptorLookupCache.java
          pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStep.java
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/Messages.properties
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/JSONValidationTest.java
          pipeline-model-definition/src/test/resources/json/errors/jsonParameterTypeCoercion.json
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/2b20c589ab6f955c12471c2061e3a2bc01b28079
          Log:
          JENKINS-42640 Fix validation of wrappers and some types

          In validating the options contents, we didn't actually look for a
          StepDescriptor, just a symbol-driven Descriptor. Which won't work for
          steps! So we never actually validated the contents of wrappers in
          options. Besides that, we needed to reject converting to int from
          String/Boolean - that gets through ScriptByteCodeAdapter.castToType,
          but not runtime.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/DescriptorLookupCache.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStep.java pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/Messages.properties pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/JSONValidationTest.java pipeline-model-definition/src/test/resources/json/errors/jsonParameterTypeCoercion.json http://jenkins-ci.org/commit/pipeline-model-definition-plugin/2b20c589ab6f955c12471c2061e3a2bc01b28079 Log: JENKINS-42640 Fix validation of wrappers and some types In validating the options contents, we didn't actually look for a StepDescriptor, just a symbol-driven Descriptor. Which won't work for steps! So we never actually validated the contents of wrappers in options. Besides that, we needed to reject converting to int from String/Boolean - that gets through ScriptByteCodeAdapter.castToType, but not runtime.

            jviolas jeremie violas
            jviolas jeremie violas
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: