使用 jenkins artifactory 插件获取构建列表?

Get a list of builds with the jenkins artifactory plugin?

https://wiki.jenkins.io/pages/viewpage.action?pageId=99910084

我可以上传和下载,但我只想查询并获取一个仓库的人工构建列表。

我想获取给定存储库的所有构建列表,以将其呈现给用户,以便他们可以选择以前的构建进行部署。

我只需要一份构建列表。我可以通过 rest 调用来完成此操作,但我已经为 Jenkins 插件配置了凭据和服务器 URL。使用该插件会很好。

我如何使用插件执行此操作(无需自己进行休息调用)?

看起来还不可能。

几个月前的这个 包含一个可能的解决方案(也称为解决方法),其中提问者发布了他们自己的答案。

为了获取构建列表,我在共享库中写了 groovy class 到 return 版本号列表和最新版本号。

刚遇到同样的要求。 Artifactory插件好像还不支持

因此我编写了以下小管道脚本。您必须 运行 它在某个具有 curl 的节点内。所以很可能这将需要 linux 节点或 cygwin 安装。

String jsonData = ""
node('linux') {
    withCredentials([usernamePassword(credentialsId: '<credentials id>', passwordVariable: 'password', usernameVariable: 'username')]) {
        jsonData = sh(returnStdout: true, script: "curl -u '$username:$password' <url to artifactory repository>")
    }
}

def json = readJSON(text: jsonData)

List<String> deployments = []
json.children.each {
    echo it.uri
    deployments << it.uri
}

deployments 变量将包含所选存储库中可用的工件列表。