How can I upload an RPM file to Artifactory using Gradle? Gradle always uploads the files using a maven-style directly layout which is inappropriate for a YUM repository.
The issue here is that Gradle insists on uploading everything in a maven-style directory format of group-id/version/artifact
, while a yum repository needs a flat layout. There are two approaches here - using the Artifactory plugin or Gradles newer publishing mechanism. I could only get this to work with the latter.
I assume here that you're using the Gradle ospackage plugin and already have an RPM build created. In my case the name of the RPM task is distRpm
. For example:
task distRpm(type: Rpm) {
packageName = 'my_package'
version = version
release = gitHash
arch = 'X86_64'
os = 'LINUX'
// Etc
}
Add the ivy publish plugin to your project:
apply plugin: 'ivy-publish'
And then add a publishing block:
publishing {
publications {
rpm(IvyPublication) {
artifact distRpm.outputs.getFiles().getSingleFile()
/* Ivy plugin forces an organisation to be set. Set it to anything
as the pattern layout later supresses it from appearing in the filename */
organisation 'dummy'
}
}
repositories {
ivy {
credentials {
username 'yourArtifactoryUsername'
password 'yourArtifactoryPassword'
}
url 'https://your-artifactory-server/artifactory/default.yum.local/'
layout "pattern", {
artifact "${distRpm.outputs.getFiles().getSingleFile().getName()}"
}
}
}
}
The Ivy Publication allows you to specify the directory and filename pattern for upload. This is overwritten to be simply the exact filename of the RPM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With