Consider the following scenarios:
A git repository contains six Java Projects A, B, C, D, E, F.
A is the underlying module. B Depends On A, C, D, E, F, and A and B at the same time. At this time, the project can be divided into three layers.
Requirements:
1. Jenkins only compiles projects with file changes
By default, as long as one git repository hasCodeThe six projects will all be compiled, which is a waste of resources.
After installing pathignore plugin, set it in each Jenkins project:
** Indicates all sub-directories in the SDK/common directory.
2. Manually specify the compilation Sequence
Because we use Maven projects, Jenkins can know the dependencies between projects based on POM. XML, so it can be automatically compiled layer by layer without setting.
However, Jenkins compiles different projects in parallel. To save server resources, you can set them manually.
You can select the project to be compiled next in build other projects.
3. You can also specify two options in advanced project options:
Block build when upstream project is building
Block build when downstream project is building
Note that 2 and 3 only control the compilation sequence, but 1 still plays a role. If the code of A is submitted and automatically compiled, and B needs to be compiled after Step 1 is specified, rule 1 checks whether B has any code changes. If code B is not modified, the compilation ends. This is very reasonable and saves a lot of resources.
Note: It is only applicable to virtual machine-based languages such as Java. If it is C ++, it is best to re-compile all projects unless you are using a technology similar to com to build the product architecture, and the interface does not change.