2016-09-21 97 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 –