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

Option for not expanding parameters

    Details

    • Similar Issues:

      Description

      When executing a groovy script which accepts some parameters as input and some parameters contain a '$' (e.g. some$pass!) the following happens:

      17:04:13 Execution of script [somescript.groovy] failed - Unrecognized macro 'pass' in 'some$pass!'org.jenkinsci.plugins.tokenmacro.MacroEvaluationException: Unrecognized macro 'pass' in 'some$pass!'
      17:04:13 	at org.jenkinsci.plugins.tokenmacro.TokenMacro.expand(TokenMacro.java:185)
      17:04:13 	at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:219)
      17:04:13 	at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:208)
      17:04:13 	at org.jenkinsci.plugins.scriptler.builder.ScriptlerBuilder.perform(ScriptlerBuilder.java:104)
      

      If I understand the code correctly the behaviour of the token-macro plugin trying to expand the contents of the parameters is wanted (JENKINS-11914 is related to this). However it is problematic when passing on parameters which contain a '$' and should not be expanded.

      Therefore a feature which lets the user define whether a specific parameter or all parameters should be expanded would be useful.

        Attachments

          Activity

          seder Stefan Prietl created issue -
          Hide
          seder Stefan Prietl added a comment - - edited

          In the meantime I did a workaround to prevent this error:

          • Upgraded to token-macro plugin 1.6
          • Used "expandAll" method with the "throwException" parameter set to "false"

          This will return the value of the parameter, if no defined build or environment variable is found. It might be a cheap solution for the stated problem but might not be the behaviour every user of this plugin is looking for (e.g. would pass on ${someVar} if not expandable to the script instead of stopping with an error).

          However it works for me.

          I attached the patch file. Maybe it is of some use.

          Show
          seder Stefan Prietl added a comment - - edited In the meantime I did a workaround to prevent this error: Upgraded to token-macro plugin 1.6 Used "expandAll" method with the "throwException" parameter set to "false" This will return the value of the parameter, if no defined build or environment variable is found. It might be a cheap solution for the stated problem but might not be the behaviour every user of this plugin is looking for (e.g. would pass on ${someVar} if not expandable to the script instead of stopping with an error). However it works for me. I attached the patch file. Maybe it is of some use.
          seder Stefan Prietl made changes -
          Field Original Value New Value
          Attachment scriptler-plugin_no_token_exceptions.patch [ 23318 ]
          domi Dominik Bartholdi made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: imod
          Path:
          pom.xml
          src/main/java/org/jenkinsci/plugins/scriptler/builder/ScriptlerBuilder.java
          http://jenkins-ci.org/commit/scriptler-plugin/587086fdbac0bcabcad37f30b5122ed7c761f7a3
          Log:
          [FIXED JENKINS-17259] don't throw exception in case Token can't be expanded

          Compare: https://github.com/jenkinsci/scriptler-plugin/compare/1cdbd6cebd39...587086fdbac0

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: imod Path: pom.xml src/main/java/org/jenkinsci/plugins/scriptler/builder/ScriptlerBuilder.java http://jenkins-ci.org/commit/scriptler-plugin/587086fdbac0bcabcad37f30b5122ed7c761f7a3 Log: [FIXED JENKINS-17259] don't throw exception in case Token can't be expanded Compare: https://github.com/jenkinsci/scriptler-plugin/compare/1cdbd6cebd39...587086fdbac0
          scm_issue_link SCM/JIRA link daemon made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 148092 ] JNJira + In-Review [ 192713 ]

            People

            • Assignee:
              domi Dominik Bartholdi
              Reporter:
              seder Stefan Prietl
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: