I am using Nexus as the repository for my project and I use Jenkins as my CI orchestrator.
At the end of my Jenkins jobs I call the Nexus REST API to rebuild the Maven metadata so the information about the latest version of every component can be updated. When the REST call is performed it returns immediately, but the update task is actually queued in Nexus and eventually is executed.
As I have several jobs running in parallel, what happens is that sometimes the builds run into a sort of race condition when one of the components is trying to pull a dependency from Nexus while the Maven metadata hasn't finished refreshing yet - thus, an old version is pulled from Nexus even though the new one is already there and the metadata is about to be refreshed.
A good way to prevent this is by making this call synchronous, i.e. block the build until the Maven metadata is actually rebuilt.
Of course I can do this programatically by polling Nexus for the latest version of the component in a loop until it's updated. However, I wonder if there's a way to do this using the Nexus API. Thoughts?