我该如何使用Gradle上传RPM文件到Artifactory?Gradle始终会使用适用于Maven的直接布局来上传文件,这对于YUM库是不合适的。
group-id/version/artifact
上传所有内容,而yum仓库需要一个平面布局。这里有两种方法-使用Artifactory插件或Gradle的新发布机制。我只能用后者使其工作。distRpm
。例如:task distRpm(type: Rpm) {
packageName = 'my_package'
version = version
release = gitHash
arch = 'X86_64'
os = 'LINUX'
// Etc
}
apply plugin: 'ivy-publish'
然后添加发布块:
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()}"
}
}
}
}
Ivy Publication允许您指定上传的目录和文件名模式。这将被覆盖为RPM的确切文件名。
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.0"
}
}
apply plugin: 'ivy-publish'
apply plugin: 'com.jfrog.artifactory'
artifactoryPublish {}.dependsOn(buildRpm)
publishing.publications.create('yum-publication', IvyPublication) {
artifact buildRpm.outputs.getFiles().getSingleFile()
}
artifactory {
contextUrl = 'https://artifactory.acme.com/artifactory' //The base Artifactory URL if not overridden by the publisher/resolver
publish {
//A closure defining publishing information
repository {
repoKey = 'demo-yum' //The Artifactory repository key to publish to
username ="${artifactory_user}"
password = "${artifactory_password}"
ivy {
artifactLayout = "${buildRpm.outputs.getFiles().getSingleFile().getName()}"
}
}
defaults {
//List of Gradle Publications (names or objects) from which to collect the list of artifacts to be deployed to Artifactory.
publications ('yum-publication')
publishBuildInfo = false //Publish build-info to Artifactory (true by default)
publishArtifacts = true //Publish artifacts to Artifactory (true by default)
publishPom = false //Publish generated POM files to Artifactory (true by default).
publishIvy = false //Publish generated Ivy descriptor files to Artifactory (true by default).
}
}
}
[originalname]
,因此您应该使用另一个占位符(例如[module]
)并将文件名放入该属性中。请查看这个最小示例。 - Lukas Körfer