【问题标题】:Verify Artifactory download in Jenkins pipeline验证 Jenkins 管道中的 Artifactory 下载
【发布时间】:2021-06-15 21:25:54
【问题描述】:

我在我的 Jenkins 管道中使用 Jfrog Artifactory 插件来提取管道使用的一些内部实用程序。我使用参数指定我想要的实用程序版本。

执行 server.download 后,我想验证并报告实际下载的文件版本,但我似乎根本找不到任何方法来做到这一点。我确实得到了从 server.download 调用返回的 buildInfo 对象,但我可以找到任何方法从该对象中提取信息。如果我尝试打印 buildInfo 对象,我只会得到一个对象引用。如果下载的实用程序版本不正确,我想中止构建并发送报告。

我的问题是,“如何验证下载规范指定的文件是否已成功下载?”

【问题讨论】:

    标签: jenkins artifactory


    【解决方案1】:

    此功能目前仅在脚本化管道上可用,并在documentation 中进行了描述。

    例如:

    node {
    def server = Artifactory.server SERVER_ID
    def downloadSpec = readFile 'downloadSpec.json'
    def buildInfo = server.download spec: downloadSpec
    
    if (buildInfo.getDependencies().size() > 0) {
        def localPath = buildInfo.getDependencies()[0].getLocalPath()
        def remotePath = buildInfo.getDependencies()[0].getRemotePath()
        def md5 = buildInfo.getDependencies()[0].getMd5()
        def sha1 = buildInfo.getDependencies()[0].getSha1()
        echo localPath
    }
    
    server.publishBuildInfo buildInfo
    }
    

    【讨论】:

    • 你会不会碰巧有一个指向文档的指针,指向 buildInfo 中的其他内容。我已经搜索了几个小时无济于事。 Edit。终于找到东西了:github.com/jfrog/build-info/blob/master/build-info-api/src/test/…
    • 仅在我上面提到的文档中记录的内容。其中大部分用于配置。如果您想查看代码,列入白名单的内容here
    猜你喜欢
    • 1970-01-01
    • 2020-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-05
    • 1970-01-01
    • 1970-01-01
    • 2016-04-19
    相关资源
    最近更新 更多