基于python的sonatype nexus oss 3 cli
nexus3-cli的Python项目详细描述
nexus3客户端
sonatype的Nexus OSS 3的基于python的命令行接口和api客户端。
notice:nexus3 cli的2.0.0版包含breaking changes,即将发布。如果您的应用程序使用nexuscli
,我建议您:
- 确定您的需求(例如:
'nexus3-cli>=1.0.2,<2
);和 - 请查看2.0.0 branch上的更改以准备升级。
一旦2.0.0发布,1.0.x版本的开发和支持将停止。
功能
- 兼容Nexus 3 OSS
- python api和命令行支持
- 工艺品管理:列表,删除,批量上传和下载。
- 存储库管理:
- 创建托管和代理。
- 创建bower、maven、npm、nuget、pypi、raw、rubygems、yum。
- 内容类型验证、版本和写入策略。
- 删除。
- groovy脚本管理:列表、上传、删除、运行。
如果端点是 可用,否则使用groovy脚本。
请注意,某些Nexus3功能目前不受支持。援助 实施缺失的支持是非常受欢迎的。请看一下 issues 以及contribution guidelines。
安装
pypi上提供了nexus3 cli包。您可以使用pip/pip3安装:
pip install nexus3-cli
用法
命令行
要快速开始,请使用sonatype/nexus3 Docker image:
docker run -d --rm -p 127.0.0.1:8081:8081 --name nexus sonatype/nexus3
Nexus需要一段时间才能在第一次运行时启动。你可以 查看Docker实例日志或浏览 http://localhost:8081。
在旧版本的nexus3 docker映像上,默认的admin
密码是
admin123
;在较新版本上,它是自动生成的,您可以找到它
通过运行docker exec nexus cat /nexus-data/admin.password
。
login
命令将服务url和凭据存储在
~/.nexus-cli
(警告:已设置限制性文件权限,但内容
以纯文本保存)。
设置cli凭据:
$ nexus3 login Nexus OSS URL (http://localhost:8081): Nexus admin username (admin): Nexus admin password (admin123): Verify server certificate (True): Configuration saved to /Users/thiago/.nexus-cli
列出存储库:
$ nexus3 repository list Name Format Type URL maven-snapshots maven2 hosted http://localhost:8081/repository/maven-snapshots maven-central maven2 proxy http://localhost:8081/repository/maven-central nuget-group nuget group http://localhost:8081/repository/nuget-group nuget.org-proxy nuget proxy http://localhost:8081/repository/nuget.org-proxy maven-releases maven2 hosted http://localhost:8081/repository/maven-releases nuget-hosted nuget hosted http://localhost:8081/repository/nuget-hosted maven-public maven2 group http://localhost:8081/repository/maven-public
创建存储库:
$ nexus3 repository create hosted raw reponame
执行递归目录上载:
$ mkdir -p /tmp/some/deep/test/path $ touch /tmp/some/deep/test/file.txt /tmp/some/deep/test/path/other.txt $ cd /tmp; nexus3 up some/ reponame/path/ Uploading some/ to reponame/path/ [################################] 2/2 - 00:00:00 Uploaded 2 files to reponame/path/
nota bene:nexus3 cli将以/
结尾的路径解释为目录。
列出存储库内容:
$ nexus3 ls reponame/path/ path/some/deep/test/path/other.txt path/some/deep/test/file.txt
对于所有命令、子命令和选项,请运行nexus3 -h
。
CLI documentation
api
从1.0.x升级
2.0.0版与1.0.0版相比有显著的API更改。总而言之:
- 引入一个
NexusConfig
类来保持服务配置的独立性 从客户那里。 NexusClient
没有long接受配置关键字参数;而是 获取一个NexusConfig
实例。- 将所有cli代码移动到
cli
包,并将api代码移动到api
包。 - 已经重写了
Repository
类,以便于添加支持 对于所有存储库。请看上面链接的2.x的手册页。 - 存储库上载方法已移动到其自己的模块中
nexuscli.api.repository.upload
再次,使支持所有 储存库。 - 已审阅文档以包含新主题并自动 在HTML输出中包含任何新类 read the docs。
- 单元测试已经过重构和重新组织,以便与
src
结构。
开发
自动测试在.travis.yml
中配置。要在本地运行测试,
安装带有测试依赖项的包并运行pytest:
pip install -e .[test] pytest -m 'not integration'
集成测试需要本地nexus实例监听8081或
在~/.nexus-cli
中配置;用于测试的示例配置位于
tests/fixtures/dot-nexus-cli
。
docker run -d --rm -p 127.0.0.1:8081:8081 --name nexus sonatype/nexus3 ./tests/wait-for-nexus.sh # the Nexus instance takes a while to be ready# use the random admin password generated by the Nexus container to login ./tests/nexus-login $(docker exec nexus cat /nexus-data/admin.password) pytest -m integration docker kill nexus
注意:如果您重新运行集成测试而不重新创建或清理 dev nexus实例,测试将失败,因为在测试期间创建的某些对象陆上通信线 已经存在。
欢迎拉取请求;请参见CONTRIBUTING.md。