Jenkins and JFrog Artifactory - how to set how many last builds should be stored?

Viewed 358

I am uploading zip packages from Jenkins to Artifactory using the Artifactory Plugin. I am using the following Upload step and it works, my only question is it possible to somehow configure how many last builds will be kept in Artifactory? (e.g. last 50 builds)

    stage ('Upload stage') {
        steps {
            rtUpload (
                serverId: 'Artifactory',
                spec: '''{
                      "files": [
                        {
                          "pattern": "package-*.zip",
                          "target": "artifactory/jenkins/"
                        }
                     ]
                }''',
            )
        }
    }

Thanks

1 Answers

You can configure build retention during the publish build info step:

stage ('Set build retention') {
    steps {
        rtBuildInfo (
            maxBuilds: 50
        )
    }
}

stage ('Upload stage') {
    steps {
        rtUpload (
            serverId: 'Artifactory',
            spec: '''{
                  "files": [
                    {
                      "pattern": "package-*.zip",
                      "target": "artifactory/jenkins/"
                    }
                 ]
            }'''
        )
    }
}

stage ('Publish build info') {
    steps {
        rtPublishBuildInfo (
            serverId: 'Artifactory'
        )
    }
}

For more information see Triggering Build Retention documentation.

Related