尝试使用REST API在sonatype Nexus中创建存储库 [英] Trying to use REST API to create repositories in sonatype Nexus
问题描述
我如何通过REST API创建存储库,并希望有人可以帮助我使用所使用的xml和curl脚本.
how do i create a repository through the REST API and was hoping someone could help me with the xml and curl script used.
推荐答案
首先,如果您对如何做这些事情感到好奇,可以在Sonatype上使用我们的这篇文章,了解如何学习Nexus Repository 2 REST API: http://www.sonatype.org/nexus/2015/01/26/learn-the-nexus-rest-api-automating-sonatype-nexus/
Firstly, if you are curious on how to do these things, you can use this article by us at Sonatype on how to learn the Nexus Repository 2 REST API: http://www.sonatype.org/nexus/2015/01/26/learn-the-nexus-rest-api-automating-sonatype-nexus/
第二,下面是一个示例,我们的内部团队成员想出了一个例子:
Secondly, here's an example one of our internal team members came up with:
这是对
This is a POST request to http://localhost:8081/nexus/service/local/repositories. You can use it like this with curl:
curl -H内容类型:application/json" -d @ repo.json -u admin:admin123
curl -H "Content-Type: application/json" -d @repo.json -u admin:admin123 http://localhost:8081/nexus/service/local/repositories
以下是上面引用的"repo.json"文件的一些示例内容,其中显示了如何创建代理Maven存储库.请注意,用于创建其他类型的存储库的有效负载将有所不同,请使用上面的文章来找出它们是什么.
Here's some sample content for the "repo.json" file referenced by the above, which shows how to create a proxy Maven repository. Note that the payload for creating other types of repositories will be different, use the article above to find out what those are.
{
"data": {
"repoType": "proxy",
"id": "somerepo",
"name": "Some Repo Name",
"browseable": true,
"indexable": true,
"notFoundCacheTTL": 1440,
"artifactMaxAge": -1,
"metadataMaxAge": 1440,
"itemMaxAge": 1440,
"repoPolicy": "RELEASE",
"provider": "maven2",
"providerRole": "org.sonatype.nexus.proxy.repository.Repository",
"downloadRemoteIndexes": true,
"autoBlockActive": true,
"fileTypeValidation": true,
"exposed": true,
"checksumPolicy": "WARN",
"remoteStorage": {
"remoteStorageUrl": "http://someplace.com/repo",
"authentication": null,
"connectionSettings": null
}
}
}
这篇关于尝试使用REST API在sonatype Nexus中创建存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!