gpt4 book ai didi

nexus - 在 Nexus 3 中自动删除组件

转载 作者:行者123 更新时间:2023-12-04 07:29:40 25 4
gpt4 key购买 nike

我正在尝试通过 nexus 3 api 删除存储库中的一些组件

我已按照以下问题中的说明进行操作 Using the Nexus3 API how do I get a list of artifacts in a repository

并按如下方式修改它以删除一个工件

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

但是当我询问 maven-metadata.xml 时 http://localhost:32769/repository/eddie-test/com/company/you-artifact-name/maven-metadata.xml该版本仍然列出。即

<metadata>
<groupId>com.company</groupId>
<artifactId>you-artifact-name</artifactId>
<versioning>
<release>1.0.7</release>
<versions>
<version>1.0.6</version>
<version>1.0.7</version>
</versions>
<lastUpdated>20161213115754</lastUpdated>
</versioning>

(通过 ui 中的删除组件按钮删除组件,按预期更新 maven-metadata.xml)

那么有没有办法确保通过API删除文件时更新了文件?

最佳答案

运行后,您可以运行重建 Maven 存储库元数据计划任务,这将完成您的目标。

目前没有用于调用该任务的公共(public) API。如果需要,请转到 https://issues.sonatype.org/browse/NEXUS并为此提出问题 :)

关于nexus - 在 Nexus 3 中自动删除组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41168427/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com