Jenkins Artifatory 管道:如何在同一存储库中将 Debian 软件包从测试发行版提升到稳定版

Jenkins Artifatory pipeline : How to promote a Debian package from a testing distribution to stable in the same repository

我有一个 Jenkins 管道来构建 .deb 包。它成功地将包上传到 Artifactory 存储库。包本身在 'pool' 中,元数据是为 'main' 组件和 'testing' 分发创建的。我的 preprod 环境通过 APT 安装包。

我现在想做的是将构建提升到同一存储库中的 'stable' 发行版(我们只有一个带有很多存储库的公司 Artifactory 实例,所以我不能有多个) .

我的管道是这样的:

#!/usr/bin/env groovy
node('XXX') {

    def artifactoryServer
    def artifactoryBuildInfo

    stage('Artifactory configuration') {
        artifactoryServer = Artifactory.newServer url: "http://mycorporateartifactoryrepo.com", credentialsId: 'XXXXX'
    }

    stage('checkout') {
        checkout scm
    }

    stage('packaging & deploying') {
        artifactoryBuildInfo = Artifactory.newBuildInfo()
        // Packaging & deploying mvn
        archiveArtifacts artifacts: "target/cowsay.deb", fingeprint: true

        // packaging & deploying deb package
        def uploadSpec = """{
            "files": [
                {
                    "pattern": "target/cowsay.deb",
                    "target": "debian-repo/pool/",
                    "props": "deb.distribution=testing;deb.component=main;deb.architecture=all"
                }
            ]
        }"""
        artifactoryBuildInfo = artifactoryServer.upload spec: uploadSpec
        artifactoryServer.publishBuildInfo artifactoryBuildInfo
    }

    stage('promotion') {
        def promotionConfig = [
            'buildName'          : artifactoryBuildInfo.name,
            'buildNumber'        : artifactoryBuildInfo.number,
            'sourceRepo'         : 'debian-repo/pool/',
            'targetRepo'         : 'debian-repo/pool/',
            'comment'            : 'Promoting build',
            'status'             : 'Released',
            'includeDependencies': true,
            'copy'               : true,
            'failFast'           : true
        ]

        // Promote build interactively if tests are OK
        Artifactory.addInteractivePromotion server: artifactoryServer, promotionConfig: promotionConfig, displayName: 'Promote me!'
    }
}

我该如何管理? Artifactory 没有记录这种可能性。我是否需要创建自定义管道来实现此目的?

谢谢

Artifactory Build Promotion 使您能够将构建标记为 'promoted'(即已发布),并可能将 Artifacts 移动或复制到不同的存储库(表示准备好发布的位置)。

但在您的情况下,可以通过修改工件上的 deb.distribution 属性 设置来更改 Debian 工件的发行版 - 这将导致它在 stable 发行版中建立索引以及(因此可以在新发行版中使用 apt)。

我建议为此在您的管道中添加一个步骤,或者完全创建一个不同的作业来促进构建,然后使用所需的属性对工件进行注释。

另一种选择是使用 user plugin that you can trigger from your job, but tagging with properties is more convenient via standard REST API 恕我直言。