A team wants two stages in one pipeline to run as group. The reason is:
They have three stages in one pipeline, and the first stage for unit test, the second one for server deployment, and the last one for functional test which will hit the servers that deployed in the previous stage 'deployServer'.
The unit test stage runs faster than the other two, so it is possable to deploy a new version of the application at the time the functional test is running if checkin frequently.
It could handle this case by cruise-resource-matching and ruby script with cruise Json APIs:
Setup a job in 'FunctionTest' stage called 'checkJob' and it needs the same resource with the job in 'deployServer' stage and will treat the script as a task.
When the third stage is running, 'checkJob' will occupy the resource and run a task which is a ruby script to check whether the other jobs in 'FunctionTest' stage are finished or not. If other jobs are finished, 'checkJob' is going will finish immidately. Once 'checkJob' finishes, the resource will release, and the new version could start to run on 'deployServer' stage agent.
The attachment is an example, including a rake file and a section of cruise-config.xml. However You have to modify them to feed your pipeline and check in the rake file to your repository if you want to use them. Also the script needs 'json-1.1.3.gem'.
Notes: It works with 1.3.
Disclaimer: The statements and opinions expressed in this article are those of the author(s) and do not necessarily reflect the positions of Thoughtworks.