View Source

h3. Scenario

In a continuous integration environment, it is very important that a build can complete in a short time to provide feedback to developer as soon as possible after they submit a build verification request.

h3. Solution

You can parallelizing CPU intensive build steps, and run them on different agent nodes. The results from different node can be collected back for further processing. Assuming a product comprises of component1 and component2, and both of them take a long time to build. You can parallelize build of component1 and component2 like below:
!parallel-build.png!
The _node match condition_ property for these steps can be specified like below:
* *master:* node.isAgent()
this tells master step to run only on agent node (in order to [reduce server load|Reduce Server Load])
* *checkout:* node==parent.node
this tells step _checkout_ to run on the same agent as the master step
* *build components:* node==parent.node
this tells step _build components_ to run on the same agent as the master step
* *build component1*: node.isAgent()
this tells step _build component1_ to run on agent node selected by load balancing algorithem
* *build component2*: node.isAgent()
this tells step _build component2_ to run on agent node selected by load balancing algorithem
* *package: node==parent.node
this tells step _package_ to run on the same agent as the master step
* *publish:* node==parent.node
this tells step _publish_ to run on the same agent as the master step

The idea here is that step _build component1_ and _build component2_ is designed to run on least loaded agent nodes, while all other steps are running in the same agent node.

There are still problems: The nodes running step _build component1_ and _build component2_ are not guaranteed to be the same node running step _checkout_. How can we make sure that necessary files are available when build component1 and component2? The same issue exists when running step _package_, how to make sure that build results of component1 and component2 are available for packaging if the build steps and package step do not run on the same agent?

This is solved by specifying file requirements for steps. Let's assume that the agent node choosed to run master step is _agent1_, and the _checkout_ step retrieves files into two folders into workspace resides on _agent1_: _component1-src_, and _component2-src_. Folder _component1-src_ contains all files used to build component1, while folder _component2-src_ contains all files used to build component2. Build results of comonent1 is saved to folder _component1-binary_, and build results of component2 is saved to folder _component2-binary_. Now we can specify file requirements as below:
* *for step _build component1_*
!file-requirement1.png!
* *for step _build component2_*
!file-requirement2.png!
* *for step _package_*
!file-requirement3.png!