4

I'm attempting to upload artifacts to Nexus 3. I have managed to successfully do it, but it looks like things are not grouped properly when I look in the UI.

I can use curl or maven with the following config and 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"
        }
    }
}

But when I do, The artifact is not grouped and therefore I can delete a directory by it's version. I have to delete every single file:

enter image description here

Is this a limitation of Nexus 3?

marchaos
  • 3,316
  • 4
  • 26
  • 35
  • What do you mean by "not grouped"? Your artifacts seem to sit in the 0.10-SNAPSHOT directory. – J Fabian Meier Sep 27 '16 at 09:38
  • I would assume that the UI would group them so that there is only one 0.1.0-SNAPSHOT item in the list, so I can click on this item to delete that version. – marchaos Sep 28 '16 at 10:45

1 Answers1

0

There is also a 'components view' which groups things per artefact

enter image description here

but if you are after the information on how to delete a component based on the artefact id and version: you can achieve it via the nexus api

read ch16 from https://books.sonatype.com/nexus-book/reference3/scripting.html to introduce you to the script way the answer there shows you how to list all the artefacts ins a repo. I've extended it here:

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")
  • answer hails from http://stackoverflow.com/questions/41063108/using-the-nexus3-api-how-do-i-get-a-list-of-artifacts-in-a-repository/41070107#41070107 – Eddie Dvorak Dec 15 '16 at 14:43