r/jenkinsci • • Mar 06 '24

Java project build step keeps failing

As a newcomer to Jenkins, I would greatly value any assistance provided.

I'm attempting to configure a build step for a Java project in Eclipse to work with Jenkins, but it continually fails.

Could someone advise me on what might be the issue? For your information, I'm using a Mac.

0 Upvotes

12 comments sorted by

7

u/simonides_ Mar 06 '24

what does the log say?

3

u/sem1845 Mar 07 '24

Logs logs logs!

1

u/sw60xg Mar 06 '24

I think it would be helpful if you provide some console output from failed job. As well as what exactly you trying to achieve with this step. Cause if this about building application shouldn’t it be something like gradle build, or mvn build?

1

u/Apprehensive-Cod9111 Mar 06 '24

Honestly, I'm simply trying to link a random Java project to Jenkins to gain some experience with importing projects into the Jenkins build system.

The error message I receive states: "command execution failed," "no such file or directory," and "cannot run program 'cmd.'"

I hope this information is helpful! Please let me know your thoughts. Thanks

2

u/onbiver9871 Mar 07 '24

I was looking at your pathing structure (eg no drive at the beginning, like C:/Users/..) and thinking about “cannot run program cmd” and then realized you already answered your own question :)

You’re trying to run a Windows batch command on a Mac. Look for an “execute bash script” option or something similar :)

1

u/Apprehensive-Cod9111 Mar 07 '24

Yes! I tried to execute this command on a shell window instead but no luck :(

1

u/onbiver9871 Mar 07 '24

What did you get back from that? Did you try it interactively in a terminal window yourself, or did you try to use Jenkins but with a bash/shell option instead of a Windows CMD option?

What logs/output did you get?

3

u/kon_dev Mar 07 '24

You are trying to execute source code, that is not a jenkins issue, it is a java problem, that command should have failed on your terminal as well.

Try compiling it first:

javac sample.java

java sample.class

3

u/JustAberrant Mar 06 '24

Very minimum that should be javac, unless java does interpretation now?

Try doing what you are doing in Jenkins from command line (since that is similar in principle to what Jenkins does when used this way).

3

u/HomosapienHomie Mar 07 '24

Bash or shell dose not register <spaces> really well, if you have spaces in between your file name try

cd /Users/clara/eclipse-workspace/Practice/src/trial\ java\ sample. java