This article describes how to create a job on the Jenkins to execute Java programs. This Java program, we only write a simple program, a Hello.java file to represent our Java program, by understanding the entire creation process, to imitate the actual work of a Java project on the Jenkins build process.
1. Write a Hello.java with Notepad, code as follows
public class hello{public
static void Main (string[] args) {for
(int i=1;i<=10;i++)
System.out.println ( "Hello World" + i);
}
Create a new folder on your desktop and put the Hello.java in the folder.
2. There is no problem with the program just written in the CMD compilation test
3. Create a Hello project on the Jenkins
4. Build command
Select Windows Batch Commond, enter the following command, click Save
It is recommended that you write an absolute path behind the first CD command, otherwise error prone.
5. Start building, test
Summarize:
I have used this example to perform my WebUI automated test script run. If you are a java+selenium, then you only need to use the batch command to execute testng.xml files. is not, so if your script is not managed with the source tools, you are a small project of one person, you can go to play like this. We'll just have to play this pattern before we think about how we're going to do it if there's a code management tool, so next we'll explain how to create a Jenkins project build on the current basis, introducing Git or SVN.