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

TOOLNAME_HOME Variable Not Available For Use in Freestyle Build Step

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • groovy-plugin
    • None

      Summary

      Attempting to use the TOOLNAME_HOME variable within an Execute system Groovy script build step causes error due to no variable expansion.
      java.io.FileNotFoundException: /jenkins-home/workspace/FreeEnvVar/${TESTTOOL_HOME}/script.groovy (No such file or directory)

      Steps to reproduce

      1. Install custom build tool plugin and system groovy script plugin
      2. Create a custom build tool called "TestTool" which downloads a file from some URL
      3. Create a freestyle job
      4. In the freestyle job, select "Install custom tools" and a Tool which has a Tool Selection of "TestTool". Be sure to select the the "Convert #ToolName_HOME variables to the upper-case"
      5. In the build steps section of the freestyle job, add a step to "Execute System Groovy script" with the "Groovy Script File" option selected and the path to the groovy script file should be "TESTTOOL_HOME"
      6. Save the job

      Expect behavior

      When you run the job, the TESTTOOL_HOME variable is correctly explanded before the System Groovy Step evalutes the file location

      Actual behavior

      When you run the job, the TESTTOOL_HOME variable is not corretly expanded by the System Groovy Step, resulting in an error like this:

      FATAL: /jenkins-home/workspace/FreeEnvVar/${TESTTOOL_HOME}/script.groovy (No such file or directory)
      java.io.FileNotFoundException: /jenkins-home/workspace/FreeEnvVar/${TESTTOOL_HOME}/script.groovy (No such file or directory)
          at java.io.FileInputStream.open0(Native Method)
          at java.io.FileInputStream.open(FileInputStream.java:195)
          at java.io.FileInputStream.<init>(FileInputStream.java:138)
          at hudson.FilePath.read(FilePath.java:1754)
          at hudson.FilePath.readToString(FilePath.java:1855)
          at hudson.plugins.groovy.FileSystemScriptSource.getSecureGroovyScript(FileSystemScriptSource.java:31)
          at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:95)
          at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:59)
          at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
          at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
          at hudson.model.Build$BuildExecution.build(Build.java:206)
          at hudson.model.Build$BuildExecution.doRun(Build.java:163)
          at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
          at hudson.model.Run.execute(Run.java:1728)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          at hudson.model.ResourceController.execute(ResourceController.java:98)
          at hudson.model.Executor.run(Executor.java:407)
      

            ataylor Alex Taylor
            ercanales Enrique Canales
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: