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

Token macro expansion not working in Groovy plugin 1.13

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Blocker
    • Resolution: Fixed
    • groovy-plugin
    • None
    • Jenkins 1.505, Groovy 1.13

    Description

      Hi,

      I've been happily using the Groovy plugin 1.12 to execute some complex code in the macro expansion.

      Unfortunately, in 1.13 it does not work anymore. This is what I get in the output of a job:

      FATAL: null
      java.lang.NullPointerException
      	at java.util.Hashtable.put(Hashtable.java:542)
      	at groovy.lang.Binding.setVariable(Binding.java:77)
      	at groovy.lang.GroovyShell.setVariable(GroovyShell.java:568)
      	at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:76)
      	at hudson.plugins.groovy.GroovyTokenMacro.evaluate(GroovyTokenMacro.java:68)
      	at org.jenkinsci.plugins.tokenmacro.DataBoundTokenMacro.evaluate(DataBoundTokenMacro.java:177)
      	at org.jenkinsci.plugins.tokenmacro.TokenMacro.expand(TokenMacro.java:177)
      	at org.jenkinsci.plugins.tokenmacro.TokenMacro.expand(TokenMacro.java:153)
      	at org.jenkinsci.plugins.buildnamesetter.BuildNameSetter.setDisplayName(BuildNameSetter.java:50)
      	at org.jenkinsci.plugins.buildnamesetter.BuildNameSetter.setUp(BuildNameSetter.java:37)
      	at hudson.model.Build$BuildExecution.doRun(Build.java:154)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:593)
      	at hudson.model.Run.execute(Run.java:1567)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      	at hudson.model.ResourceController.execute(ResourceController.java:88)
      	at hudson.model.Executor.run(Executor.java:237)
      

      For the test I used the Build Name Setter plugin with the option

      ${GROOVY,script="return 'build_name'"}
      

      but the failure is reproducible with anything that call token expansion and with any Groovy code (I use something more complex than that in my real jobs).

      To be able to work I had to revert 1.12, but I would profit from the change in 1.13 because I actually need to manipulate an environment variable in the token.

      Thanks
      Marco

      Attachments

        Activity

          I have prepared this simple fix:
          https://github.com/kartoflanka/groovy-plugin/commit/3109383f130768a7d35691366a7d7c2362560c9b

          The macro expansion for GROOVY works again now.

          savoy Sławomir Jodyński added a comment - I have prepared this simple fix: https://github.com/kartoflanka/groovy-plugin/commit/3109383f130768a7d35691366a7d7c2362560c9b The macro expansion for GROOVY works again now.
          stevejansen Steve Jansen added a comment -

          @Slawomir - I packaged this as a GitHub pull request

          See https://github.com/jenkinsci/groovy-plugin/pull/14

          stevejansen Steve Jansen added a comment - @Slawomir - I packaged this as a GitHub pull request See https://github.com/jenkinsci/groovy-plugin/pull/14
          vjuranek vjuranek added a comment -

          fixed by PR #14, fixed version 1.18.

          vjuranek vjuranek added a comment - fixed by PR #14, fixed version 1.18.

          Code changed in jenkins
          User: Slawomir Jodynski
          Path:
          src/main/java/hudson/plugins/groovy/SystemGroovy.java
          http://jenkins-ci.org/commit/groovy-plugin/612689f61c596a6065c833fa036b3a9c3d2ae689
          Log:
          fixes JENKINS-17171 - token macro expansion not working

          see https://issues.jenkins-ci.org/browse/JENKINS-17170

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Slawomir Jodynski Path: src/main/java/hudson/plugins/groovy/SystemGroovy.java http://jenkins-ci.org/commit/groovy-plugin/612689f61c596a6065c833fa036b3a9c3d2ae689 Log: fixes JENKINS-17171 - token macro expansion not working see https://issues.jenkins-ci.org/browse/JENKINS-17170

          People

            lvotypkova Lucie Votypkova
            marcocle Marco Clemencic
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: