2016-09-21 92 views
4

我试图上传工件到Nexus 3.我已经成功地做到了这一点,但是看起来在用户界面中看起来事情没有正确分组。上传工件到Nexus 3

我可以使用curl或maven以下配置和URL。

uploadArchives { 
    repositories { 
     mavenDeployer { 
      repository(url: "http://localhost:8081/repository/my-snapshot/") { 
       authentication(userName: "admin", password: "admin123") 
      } 
      pom.version = "${version}-SNAPSHOT" 
      pom.artifactId = "my-server" 
      pom.groupId = "com.example" 
     } 
    } 
} 

但是,当我这样做,工件没有分组,因此我可以通过它的版本删除一个目录。我要删除的每一个文件:

enter image description here

这是3的Nexus的限制?

+0

你是什么意思的“未分组”?您的工件似乎位于0.10-SNAPSHOT目录中。 –

+0

我会假设UI将它们分组,以便列表中只有一个0.1.0-SNAPSHOT项目,所以我可以单击此项目以删除该版本。 – marchaos

回答

0

还有一个“组件视图”每假象

enter image description here

,但如果你是如何基于制造品标识和版本删除组件的信息之后,集团的事情: 可以通过nexus api实现它

https://books.sonatype.com/nexus-book/reference3/scripting.html读取ch16以向您介绍脚本方式 答案在那里显示如何列出所有的回报文物。我在这里扩展它:

import groovy.json.JsonOutput 
import org.sonatype.nexus.repository.storage.Component 
import org.sonatype.nexus.repository.storage.Query 
import org.sonatype.nexus.repository.storage.StorageFacet 

def repoName = "eddie-test" 
def startDate = "2016/01/01" 
def artifactName = "you-artifact-name" 
def artifactVersion = "1.0.6" 

log.info(" Attempting to delete for repository: ${repoName} as of startDate: ${startDate}") 

def repo = repository.repositoryManager.get(repoName) 
StorageFacet storageFacet = repo.facet(StorageFacet) 
def tx = storageFacet.txSupplier().get() 

tx.begin() 

// build a query to return a list of components scoped by name and version 
Iterable<Component> foundComponents = tx.findComponents(Query.builder().where('name = ').param(artifactName).and('version = ').param(artifactVersion).build(), [repo]) 

// extra logic for validation goes here 
if (foundComponents.size() == 1) { 
    tx.deleteComponent(foundComponents[0]) 
} 

tx.commit() 
log.info("done") 
+0

回答来自http://stackoverflow.com/questions/41063108/using-the-nexus3-api-how-do-i-get-a-list-of-artifacts-in-a-repository/41070107#41070107 –