Reputation: 349
I am new to jenkins. I have created a demo hello world print java file with following code :
public class Hello{
public static void main(String args[]){
System.out.println("Hello World");
}
}
Saved this file in Jenkins workspace folder. When I build this file using jenkins then on command line i am getting following output :
C:\.jenkins\workspace\first_project>javac Hello.java
C:\.jenkins\workspace\first_project>exit 0
Finished: SUCCESS
But in this console window there is nowhere text as 'Hello World'. Please help me out how can I print this on console window. Thanks in advance.
Upvotes: 0
Views: 6104
Reputation: 7400
javac Hello.java
means compile the program, not run it. You probably want to run it afterwards, e.g. through a shell-command?
Upvotes: 3
Reputation: 3295
Jenkins redirects output to per-job logs. In this manner, such output can be differentiated from other jobs, otherwise the output of jobs running in parallel would be very difficult to decipher.
Look at the output for your job in the Jenkins UI, you should find what you are looking for. Locating build output from Jenkins covers this as well.
Upvotes: 1
Reputation: 1147
Using
System.out.println("Hello World");
Is a bad practice, consider using slf4j or any other logging library Logs with slf4j looked good on Jenkins on any project I worked on. Create a logger
private static final Logger LOG = LoggerFactory.getLogger(LoggableClass.class);
And log with the severity you need
LOG.debug("The message");
Upvotes: 0