我试图通过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删除时更新文件?
答案 0 :(得分:2)
运行此命令后,您可以运行Rebuild Maven存储库元数据计划任务,这将完成您的目标。
目前没有用于调用该任务的公共API。如果您愿意,可以弹出https://issues.sonatype.org/browse/NEXUS并为此提出问题:)