如何在Jenkinsfile中将Artifactory throwsOldBuilds设置为true? [英] How to set Artifactory discardOldBuilds to true in a Jenkinsfile?

查看:133
本文介绍了如何在Jenkinsfile中将Artifactory throwsOldBuilds设置为true?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jenkins Multibranch Pipelines实施构建工作.最后阶段是将构建输出上传到Artifactory.

I am working on implementing a build job using Jenkins Multibranch Pipelines. The final stage is uploading the build output to Artifactory.

通过界面配置独立作业时,有一个选项从Artifactory丢弃旧版本",这使我只能保留与要保留的最大版本数"设置中指定的相同数量的版本.

When configuring a standalone job via the interface, there is an option to "Discard old builds from Artifactory" which allows me to only keep the same number of builds as specified in "Max # of builds to keep" setting.

我的Jenkins文件中的上传阶段配置如下: https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+-+Working+With+the+Pipeline+Jenkins+Plugin

The upload stage in my Jenkinsfile is configured like this: https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+-+Working+With+the+Pipeline+Jenkins+Plugin

...并且我的Jenkinsfile中也包含以下内容,它清理了Jenkins工作区中的构建:

... and I also have the following in my Jenkinsfile which does clean-up the builds in the Jenkins workspace:

properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '10']]])

如何在Jenkinsfile中将throwsOldBuilds设置为true,以便也可以清理Artifactory中存储的构建?

How can I set discardOldBuilds to true in my Jenkinsfile so I can also clean-up the builds stored in Artifactory?

推荐答案

此问题已在最新的Artifactory Jenkins插件中修复.

This has been fixed in the latest Artifactory Jenkins plugin.

根据文档,要在将构建信息发布到Artifactory时触发构建保留,请使用以下方法:

As per the documentation, to trigger build retention when publishing build-info to Artifactory, use the following method:

buildInfo retention maxBuilds: 10
buildInfo retention maxDays: 7
// deleteBuildArtifacts is false by default.

buildInfo retention maxBuilds: 10, maxDays: 7, doNotDiscardBuilds: ["3", "4"], deleteBuildArtifacts: true

这篇关于如何在Jenkinsfile中将Artifactory throwsOldBuilds设置为true?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆