Sonatype Nexus:同步REST调用 [英] Sonatype Nexus: synchronous REST calls

查看:133
本文介绍了Sonatype Nexus:同步REST调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Nexus用作项目的存储库,并将Jenkins用作CI协调器.

I am using Nexus as the repository for my project and I use Jenkins as my CI orchestrator.

在Jenkins作业结束时,我调用Nexus REST API来重建Maven元数据,以便可以更新有关每个组件的最新版本的信息.执行REST调用后,它会立即返回,但更新任务实际上已在Nexus中排队,并最终被执行.

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.

由于我有多个并行运行的作业,所以发生的情况是,有时某个组件试图从Nexus提取依赖关系而Maven元数据尚未完成刷新时,构建会遇到某种竞争状况-因此,即使新版本已经存在并且元数据也将要刷新,也会从Nexus中提取旧版本.

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.

防止这种情况的一种好方法是使此调用同步,即阻塞构建,直到实际重建Maven元数据为止.

A good way to prevent this is by making this call synchronous, i.e. block the build until the Maven metadata is actually rebuilt.

我当然可以通过编程方式循环执行Nexus,直到循环更新该组件的最新版本为止.但是,我想知道是否有一种使用Nexus API的方法.有想法吗?

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?

推荐答案

经过大量研究,我找不到关于此的任何文档,并且在这里也没有得到任何答复.我通过以编程方式检查Maven元数据直到更新它来解决了这个问题.

After a lot of research I couldn't find any documentation on this and also got no reply here. I solved the issue by programmatically checking the Maven metadata until it is updated.

这篇关于Sonatype Nexus:同步REST调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆