从Gradle上传一个RPM到Artifactory [英] Upload an RPM to Artifactory from Gradle

查看:154
本文介绍了从Gradle上传一个RPM到Artifactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Gradle将RPM文件上传到Artifactory? Gradle总是使用Maven风格的直接布局来上传文件,这对于YUM存储库是不合适的。

解决方案

Gradle坚持以maven风格的目录格式( group-id / version / artifact )上传所有内容,而yum存储库需要平面布局。这里有两种方法 - 使用Artifactory插件或Gradle更新的发布机制。我只能得到它与后者一起工作。



我在这里假设您使用 Gradle ospackage插件,并且已经创建了RPM版本。在我的情况下,RPM任务的名称是 distRpm 。例如:
$ b

task distRpm(type:Rpm){
packageName ='my_package '
version = version
release = gitHash
arch ='X86_64'
os ='LINUX'
//等
}

将ivy发布插件添加到您的项目中:

  apply plugin:'ivy-publish'

然后添加一个发布区块:

  publishing {
publications {
rpm(IvyPublication){
artifact distRpm.outputs.getFiles()。getSingleFile()
/ * Ivy插件强制设置组织。将它设置为任何
,因为模式布局稍后会抑制它出现在文件名中* /
organization'dummy'
}
}
存储库{
ivy {
凭证{
用户名'yourArtifactoryUsername'
密码'yourArtifactoryPassword'
}
url'https://your-artifactory-server/artifactory/default.yum .local /'
layoutpattern,{
artifact$ {distRpm.outputs.getFiles()。getSingleFile()。getName()}
}
}


常春藤出版物允许您指定目录和文件名模式上传。这被覆盖为RPM的确切文件名。


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.

这篇关于从Gradle上传一个RPM到Artifactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆