How to compile and run a simple java program in Jenkins
1. Before you run and compile the code you have already installed java on your system, by default Jenkins environment setups like the path of java, Then Write a java class and placed on your desired location then run the Jenkins, by default Jenkins run on 8080 port. go to https://localhost:8080 then follow the below steps to compile and execute the java class in Jenkins.
2. After logging into the Jenkins, Jenkins dashboard should be like below.
3. Go to the Jenkins dashboard and Click on New Item
4. In the next screen, enter the Item name, in this case, I have named it java. Choose the ‘Freestyle project option.
5. The following screen will come up in which you can specify the Description of the job.
6. We need to specify the location of files which need to be built. In this example, I used the custom workspace to specify the java class location.
7. Now go to the Build section and click on Add build step → Execute Windows batch command. In the command window, enter the following commands javac Helloworld.java java HelloWorld
Then click on the save button.
8. Once saved, you can click on the Build Now option to see if you have successfully defined the job.
9. Once the build is completed, a status of the build will show if the build was successful or not. In my case, the following build has been executed successfully. Click on the #1 in the Build history to bring up the details of the build.
0 Response to "How to compile and run a simple java program in Jenkins"
Post a Comment