在Nexus中本地缓存特定工件

时间:2015-04-14 01:33:41

标签: maven nexus

我目前正在评估Nexus是否符合我们公司的要求。我似乎无法在手册中找到我需要的东西,所以我想在放弃之前我会问。

我们有严格的要求,只有经过特别授权的OSS库(及其依赖项)才能用于开发。我们希望在不放弃自动解决传递依赖性的情况下实现这一目标,因此Nexus似乎是一个很好的工具。

我们的想法是,我们可以将所有代理存储库保持在“阻止”模式,从而允许Nexus提供本地缓存的工件,但如果构建要求某些尚未缓存的内容,则拒绝访问Internet。

然后,“OSS管理员”(人员)将使用其管理员ID登录,将存储库从“阻止”模式中取出,然后以某种方式告诉Nexus下载他要授权的库列表。在所有库及其依赖项都已在本地缓存之后,他会将存储库重新置于“阻塞”模式。

我似乎无法找到一种方法来告诉Nexus从UI下载库及其依赖项。 “OSS Manager”不是开发人员,因此每次想要添加授权库时都不需要设置自定义Maven或Gradle构建。

我可以用裸Nexus(或者插件吗?)来实现这一点,或者我是否需要编写一个自定义应用程序,“OSS管理器”将使用该应用程序根据所需库列表生成假Maven构建,以及然后在Nexus实例处于“Unblocked”状态时运行该构建?

1 个答案:

答案 0 :(得分:-1)

常规Nexus代理系统信息库会在请求模块时下载这些模块。例如,在Python中,将执行以下命令以下载 pytest 模块及其所有依赖项:

george@my-box 10:34 ~/src/myproj> pip install pytest
Looking in indexes: http://10.1.2.3/nexus/repository/pypi-proxy/simple
Collecting pytest
  Downloading http://10.1.2.3/nexus/repository/pypi-proxy/packages/7e/16/83b2a35c427b838df9836c9e7e4ae6dfbcbdea643db44652f693b1c57d70/pytest-4.4.0-py2.py3-none-any.whl (223kB)
    100% |████████████████████████████████| 225kB 43.3MB/s 
Collecting pluggy>=0.9 (from pytest)
  Downloading http://10.1.2.3/nexus/repository/pypi-proxy/packages/84/e8/4ddac125b5a0e84ea6ffc93cfccf1e7ee1924e88f53c64e98227f0af2a5f/pluggy-0.9.0-py2.py3-none-any.whl
Collecting more-itertools>=4.0.0; python_version > "2.7" (from pytest)
  Downloading http://10.1.2.3/nexus/repository/pypi-proxy/packages/b3/73/64fb5922b745fc1daee8a2880d907d2a70d9c7bb71eea86fcb9445daab5e/more_itertools-7.0.0-py3-none-any.whl (53kB)
    100% |████████████████████████████████| 61kB 30.9MB/s 
Collecting atomicwrites>=1.0 (from pytest)
  Downloading http://10.1.2.3/nexus/repository/pypi-proxy/packages/52/90/6155aa926f43f2b2a22b01be7241be3bfd1ceaf7d0b3267213e8127d41f4/atomicwrites-1.3.0-py2.py3-none-any.whl
Collecting attrs>=17.4.0 (from pytest)
  Downloading http://10.1.2.3/nexus/repository/pypi-proxy/packages/23/96/d828354fa2dbdf216eaa7b7de0db692f12c234f7ef888cc14980ef40d1d2/attrs-19.1.0-py2.py3-none-any.whl
Requirement already satisfied: six>=1.10.0 in /home/george/miniconda3/lib/python3.7/site-packages (from pytest) (1.11.0)
Collecting py>=1.5.0 (from pytest)
  Downloading http://10.1.2.3/nexus/repository/pypi-proxy/packages/76/bc/394ad449851729244a97857ee14d7cba61ddb268dce3db538ba2f2ba1f0f/py-1.8.0-py2.py3-none-any.whl (83kB)
    100% |████████████████████████████████| 92kB 34.8MB/s 
Requirement already satisfied: setuptools in /home/george/miniconda3/lib/python3.7/site-packages (from pytest) (40.2.0)
Installing collected packages: pluggy, more-itertools, atomicwrites, attrs, py, pytest
Successfully installed atomicwrites-1.3.0 attrs-19.1.0 more-itertools-7.0.0 pluggy-0.9.0 py-1.8.0 pytest-4.4.0

因此,缓存 pytest 模块的过程以及您用户的所有必需依赖项将是:

  1. 取消阻止pypi-proxy存储库
  2. 执行pip install pytest
  3. 阻止pypi-proxy存储库