Paul D Smith
Paul D Smith

Reputation: 749

Is it possible to automate setting of Artifactory properties?

Artifactory seems to automatically generate properties for RPMs, Python wheels etc. Can I extend this function for my own file formats?

I've read the documentation and this talks about the REST API etc but I want to have Artifactory pull properties straight out of the file that I'm uploading.

None yet - I'm asking how.

Upvotes: 0

Views: 236

Answers (1)

DarthFennec
DarthFennec

Reputation: 2778

The logic that automatically generates properties for RPMs etc is hardcoded into each package type Artifactory supports, and you can't add custom repository types.

What you can do is write a user plugin which runs whenever a file is uploaded, reads the file, and adds the appropriate properties. For example:

storage {
    afterCreate { item ->
        if (!item.isFolder() && item.name.endsWith(".customext")) {
            def fstream = repositories.getContent(item.repoPath).inputStream
            // read fstream and generate properties
            repositories.setProperty(item.repoPath, propName, propVal)
        }
    }
}

Some notes:

  • The language is Groovy. If you aren't familiar with Groovy, in a pinch you can pretend it's Java, since most Java is also valid Groovy.
  • User plugin documentation is here
  • User plugin API Javadoc is here
  • For reference, the officially supported plugins are all here

Upvotes: 2

Related Questions