jenkinsgetgauge

Why does Jenkins use a different temp folder when launched from jar or from a service?


I have been trying to launch a testing app from Jenkins . Initially I started Jenkins from the Jar file and things were working fine.

This was the console output:

Started by user ABC
Building in workspace C:\MyDir
[xyz] $ cmd /c call C:\Users\usrname\AppData\Local\Temp\hudson2329759222967199349.bat
...

Now when I start Jenkins as a Windows service

Started by user ABC
Building in workspace C:\MyDIr
[xyz] $ cmd /c call C:\WINDOWS\TEMP\hudson4009309858990093371.bat
C:\MyDir>gauge specs 
Failed to start gauge API: Plugin 'java' not installed on following locations : [C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\gauge\plugins]

Why does it run it from a different temp folder? I tried rectifying things by adding the AppData\Local\Temp path to jenkins.xml

<executable>java</executable>
  <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle
    "-Dhudson.model.DirectoryBrowserSupport.CSP=sandbox allow-scripts; default-src 'self' 'unsafe-inline' ; img-src 'self'; style-src 'self' 'unsafe-inline';"
    -Djava.io.tmpdir="C:/Users/username/AppData/Local/Temp" 
  -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>

If it helps: Jenkins is installed in C:\Users\username.jenkins The Jenkins page just refuses to load. What should I do?


Solution

  • The Local System account in Windows uses its profile from C:\Windows\System32\Config\systemprofile. temp etc folders are refered from this location when running the process under Local System. Refer to this answer for details on this.

    In your scenario, you have the below options: