Guest
Guest

Reputation: 1

Jenkins- Unable to execute shell command

I am very new to Jenkins and getting an issue which I think is related to path setting:

I have a simple Java program which I am able to run using Terminal following below commands:

cd /Users/john/IdeaProjects/HelloWorld
javac HelloWorld.java
java HelloWorld

I have put same commands in Jenkins project- Execute shell window and getting error as below, please guide me:

Console output:

Running as SYSTEM Building in workspace /Users/Shared/Jenkins/Home/workspace/HelloWorld [HelloWorld] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/jenkins4399115153751264307.sh + cd /Users/swyam/IdeaProjects/HelloWorld + javac HelloWorld.java HelloWorld.java:1: error: error while writing HelloWorld: /Users/swyam/IdeaProjects/HelloWorld/HelloWorld.class public class HelloWorld { ^ 1 error Build step 'Execute shell' marked build as failure Finished: FAILURE

Upvotes: 0

Views: 808

Answers (1)

Shubham Gorlewar
Shubham Gorlewar

Reputation: 434

shebang :

#!/bin/sh

use shebang in first line of shell command then call your java code. Hope this helps if it works then please mark it as tick

Upvotes: 0

Related Questions