After installing the Jenkins, we start creating new job.
1. Give Job names (your project name):
2. Go to "Source Code Management tab":
Connect to Source code:
3. Go to the ' Build ' tab, using the Drop menu, to select a step.
Normally like a web app, you can select "Excute Shell"/"Excute Windows Batch Command".
Here, because we use Java application as a example, so we select "Invoke top-level Maven targets".
4. Give the command should be excuted.
In the example, we just need to use ' mvn compile ' to compile a Java app.
5. In some case, the root dir was not the app's root dir, you can click on "Advanced" button to add more information. (see the pic above)
6. After those step, your is able to build the application by clicking "Build Now".
So now Jenkins would do the following steps:
- Go to our GitHub, clone the source code and put the code inside "~/.jenkins/workspace/atomsphere" folder.
- Output file (if any) would be also put inside the This folder.
Usually the output files would be some file we want to use, for example a Web app, the output might is the bundle files tha T we want to served.
Now everytime you click on "Build Now" button, it'll re-generate new files and discard the previous files. But we might want to keep the history instead of the throw those away.
7. Archive Previous Version files
We can actaully choose which files (folder) actually we want to keep. For web app, it might is just one "dist" folder.
Here we want to keep jar file which generated by Comiler.
8. Now after we build again, we'll get a copy:
9. You might also want to clean the files after some time and you can also chain the command together. such as:
MVN CLEANMVN Package
Those Jenkins job is actually saved into a config. file inside "Workspace/[job_name]" folder.
If anything change on the This file manully, you can also click the "Reload Configuration from Disk" to get latest changes.
[Jenkins] Creating Application Builds