使用 Jenkins 和 Generic-Artifactory Integration 时如何指定版本号?

How to specify version number when using Jenkins and Generic-Artifactory Integration?

我能够将 jenkins 与 artifactory 集成,以便在执行构建时存储我的工件,但是每当推送新工件时,旧版本将自动删除。

所以我想检查一下是否可以根据版本号或构建号标记每个工件以便于版本控制。

确保在工件路径和名称中包含 Jenkins ${env.BUILD_NUMBER}

假设您的 Artifactory 存储库设置为 Maven 存储库,您的管道应包括如下内容:

def uploadSpec = """{
    "files": [
        {
            "pattern": "${env.PACKAGING_FOLDER}/${env.REPOSITORY_APPLICATION}-${env.BUILD_NUMBER}.zip",
            "target": "${env.REPOSITORY_CODE}/${env.REPOSITORY_GROUP}/${env.REPOSITORY_APPLICATION}/${env.BUILD_NUMBER}/${env.REPOSITORY_APPLICATION}-${env.BUILD_NUMBER}.zip",
            "regexp": "true"
        }
    ]
}"""

def buildInfo = Artifactory.newBuildInfo()
buildInfo.env.capture = true

buildInfo = server.upload(uploadSpec)
server.publishBuildInfo(buildInfo)