3

When running the batch commando below, this works but when doing it in Jenkins, I get an error. I have read some topics and I have the java jre installed and have the systems variables (path & java_home) also correct.

cd C:\Users\muhar\Desktop\JavaProjects
javac HelloWorld.java
java HelloWorld

Error in Jenkins:

Started by user admin
Building on master in workspace C:\Program Files (x86)\Jenkins\workspace\HelloWorld
[HelloWorld] $ cmd /c call C:\Windows\TEMP\jenkins7014006052240288157.bat

C:\Program Files (x86)\Jenkins\workspace\HelloWorld>cd C:\Users\muhar\Desktop\JavaProjects 

C:\Users\muhar\Desktop\JavaProjects>javac HelloWorld.java 
'javac' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\muhar\Desktop\JavaProjects>java HelloWorld 
'java' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\muhar\Desktop\JavaProjects>exit 9009 
Build step 'Voer Windows batch commando uit.' marked build as failure
Finished: FAILURE

Env vars

So, I am not sure what I am doing wrong here. Can anyone help?

Draken
  • 3,134
  • 13
  • 34
  • 54
  • 1
    Hi, I found the answer: when creating a new item in Jenkins, you can choose the jdk in the General tab (execute multiple builds if necessary option), either you click on System or the jdk that you have installed on that moment (jdk1.8.0_181). When I chose jdk1.8.0_181, the build was succesful. I am glad I found it but is this standard that I have to choose this because I don't see it anywhere mentioned when going to similar topics with the same issue. –  Oct 14 '18 at 15:55

1 Answers1

0

You may check used system variables in Manage Jenkins - System Information. I will recommend you to restart Jenkins and workstation due to changing may not be applied yet.

  • When checking Jenkins - System Information, I don't see the PATH & JAVA_HOME coming back. I have closed and restarted Jenkins several time and it still isn't changing, even after I clicked update automatically. –  Oct 14 '18 at 09:32
  • When I check my path in Jenkins I see the next: Path C:\Windows\System32;C:\Users\muhar\AppData\Local\Microsoft\WindowsApps;C:\Users\muhar\.dotnet\tools which is different from the path in my system variable on my computer. Is there any link there? –  Oct 14 '18 at 09:56
  • 1
    Hi, I found the answer: when creating a new item in Jenkins, you can choose the jdk in the General tab (execute multiple builds if necessary option), either you click on System or the jdk that you have installed on that moment (jdk1.8.0_181). When I chose jdk1.8.0_181, the build was succesful. I am glad I found it but is this standard that I have to choose this because I don't see it anywhere mentioned when going to similar topics with the same issue. –  Oct 14 '18 at 15:55