1
votes

My team has recently started using the interactive promotion feature of the Jenkins Artifactory plugin to start from build-output to qa-ready. I've included our upload script at the bottom for reference. This has been an easy and very effective way to handle our promotion process. We are still new to Artifactory in general as well.

We use build retention policies which work on build-output as expected. However, the builds that get promoted to qa-ready don't have build retention policies on them once in qa-ready so they just pile up until someone manually deletes them. According to the documentation there isn't a direct way via the addInteractivePromotion command but is there a different way to implement build retention policy on promoted builds in their new location?

We're using Artifactory Pro 6.5.3.

void uploadToArtifactory(String fileFullPath) {
    //build retention
    def buildInfo = Artifactory.newBuildInfo()
    buildInfo.retention maxBuilds: 5, deleteBuildArtifacts: true

    def artifactory_server = Artifactory.server 'artifactory'
    def upload_spec = """{
        "files":[
            {
                "pattern": \"""" + fileFullPath + """\",
                "target": \"build-output/${ProductVersion}/\",
                "regexp": "true"
            }
        ]
    }"""
    def promotion_config = [
        'buildName': buildInfo.name,
        'buildNumber': buildInfo.number,
        'targetRepo': 'qa-ready'
    ]

    Artifactory.addInteractivePromotion(server: artifactory_server, promotionConfig: promotion_config)
    artifactory_server.upload(upload_spec, buildInfo)
    artifactory_server.publishBuildInfo(buildInfo)
}
1
How do you see if there is no retention policy on your builds ? is it visible somewhere as metadata or is it only the consequence that indicates the absence of retention policyMuhammad Faizan-Ul-Haq
I don't think you can specifically see the retention policy within the Artifactory UI (as far as I'm aware). The way we generally identify it is if there are more builds than expected after the retention policy should have cleared one or more builds.Kettch19

1 Answers

0
votes

I had also faced the similar issue. We were using Jenkins for uploading to artifactory.

Artifactory retention ignores/discards all the builds that were promoted using the api.

This can be visible in the logs.I don't think so the build discard policy has some kind of option to set the status of the promotion that will be considered as a candidate for deletion

I have written a python script that in turn uses the aql to list all the repos based on regex ignore released artifacts and you can set the deletion based on the no. of days.