如何在Jenkins流水线中使用Artifactory插件设置现有工件的属性

3

目标: 使用声明性Jenkins流水线从Artifactory下载一个构件,运行测试,并根据测试结果设置Artifactory中构件的属性值。

问题所在: 如何在Jenkins流水线中使用Artifactory插件设置现有构件的属性?

部分代码:

pipeline {
    stages {
        stage("Load") {
            steps {
                // Get the firmware from Artifactory
                script {
                    def artServer = Artifactory.newServer url: '~~~'
                    def downloadSpecInline = """{
                        "files": [
                            {
                                "pattern": "${artRepo}/*thing-*${artBuildNo}*-class.zip",
                                "recursive": "true",
                                "flat": "true"
                            }
                        ]
                    }"""
                    def artifactBuildInfo = artServer.download(downloadSpecInline)

                    // Unknown part
                    doSomeTest()
                    artifactBuildInfo.setProperty qa.level, awesome
                }
            }
        }
    }
}
1个回答

0

你可以直接使用插件。

def server = Artifactory.server "${_artifactoryServer}"
def propsSpec = """{
    "files": [
        {
            "pattern": "${my_repo}/*/*/${_filename}"
        }
    ]
}"""
server.setProps spec: propsSpec, props: "${_property}=${_value}", failNoOp: true
要注意的一件事是:如果您没有指定文件名(即长度为零),API 将把属性写入存储库中的每个工件。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接