I have the following Maven project setup in SCM:
- A
- B (depends on A)
- C (depends on A and B, builds an archive containing artifacts from A and B)
I have organized Jenkins so there are sets of jobs where A runs, then B, then C. For example, I have a set of builds triggered by SCM commit (mvn clean install), a set of builds which run reports (mvn clean site), and sets of builds which deploy to our development/test/production servers (mvn clean install + run some plugins to deploy).
Problems happen when the jobs run concurrently. For instance:
- If the C commit job is building the same time as the A commit job, the the C commit job often has trouble reading from the local m2 repo since the A commit job may be writing to the local m2 repo.
- If the Commit jobs are running the same time as the Deploy jobs, then I am concerned that they are writing to and reading from the same local m2 repo.
Ideally I want to keep the ability to run these sets of jobs concurrently.
- Currently I am blocking downstream jobs from running when an upstream job is building. That has prevented some issues. However, I still have an issue where C is in the middle of building and then A starts to build. Are there any known issues with enabling both “Block build when upstream project is building” and “Block build when downstream project is building”?
- Can I configure Jenkins such that a set of jobs use the same Maven repository? For instance, I would like the commit triggered jobs to use one repository and use another repository for the development deploy jobs. Is this the correct solution for what I want or is there another way?
To answer the first part of your question –
You should be able to use both “Block build when upstream project is building“
and “Block build when downstream project is building” in the same job-configuration.
This will prevent Job-A from starting when Job-B or Job-C are already running,
and will prevent Job-C from starting when Job-A or Job-B are already running.
Cheers