【问题标题】:Uploading artifacts to Nexus 3将工件上传到 Nexus 3
【发布时间】:2017-01-29 12:10:30
【问题描述】:

我正在尝试将工件上传到 Nexus 3。我已经成功地做到了,但是当我查看 UI 时,似乎没有正确分组。

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

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"
        }
    }
}

但是当我这样做时,工件没有分组,因此我可以按其版本删除目录。我必须删除每个文件:

这是 Nexus 3 的限制吗?

【问题讨论】:

  • “未分组”是什么意思?您的工件似乎位于 0.10-SNAPSHOT 目录中。
  • 我会假设 UI 会对它们进行分组,以便列表中只有一个 0.1.0-SNAPSHOT 项目,因此我可以单击该项目以删除该版本。

标签: maven gradle nexus


【解决方案1】:

还有一个“组件视图”,可以根据工件对事物进行分组

但是,如果您想了解如何根据工件 ID 和版本删除组件的信息: 你可以通过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")

【讨论】:

猜你喜欢
  • 2015-12-29
  • 2017-01-04
  • 1970-01-01
  • 2011-05-01
  • 2018-12-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-30
相关资源
最近更新 更多