Get Single Build Cleanup Policy by Key API

JFrog REST APIs

Content Type
REST API

Description: This API is called to provide details on a single build cleanup policy.

Security: Requires a platform admin. A project admin with permission can call this API on the project level.

Produces: application/json

Usage: GET /artifactory/api/cleanup/builds/policies/{policyKey}

Query Parameters:

Field

Type

Description

policyKey

string

The ID that identifies the policy. This ID was configured when creating the policy. You can find the policy ID by calling Get All Build Cleanup Policies API, searching the results for the appropriate description and then its corresponding ID.

Sample Query

GET https://[JFrogPlatformURL]/artifactory/api/cleanup/builds/policies/key1

Sample Response:

{
    "key": "key1",
    "description": "some test description",
    "cronExp": "0 15 10 * * ? 2025",
    "itemType": "build",
    "durationInMinutes": 150,
    "enabled": true,
    "deleteArtifacts": true,
    "skipTrashcan": false,
    "searchCriteria": {
        "includeAllProjects": true,
        "includedProjects": [],
        "includedBuilds": [
            {
                "name": "myBuild",
                "projectKey": "default"
            }
        ],
	"excludeBuildsWithReleaseBundles": false,
        "createdBeforeInMonths": 24
    }
}

The response include the following information:

Parameter

Type

Description

key

String

A unique identifier for the cleanup policy (for example, "key1"). This is a required field and must be unique.

Note

A minimum of three characters is required, including letters, numbers, underscore and hyphen.

description

String

A brief description of the cleanup policy (optional).

cronExp

String

A cron expression specifying when the cleanup job will run (for example, 0 0 2 * * ?).

Note

This parameter is not mandatory, however if left empty the policy will not run automatically and can only be triggered manually.

itemType

String

The type of items to clean up (build). This field is required.

durationInMinutes

Integer

The maximum duration (in minutes) for policy execution, after which the policy will stop running even if not completed. While setting a maximum run duration for a policy is useful for adhering to a strict cleanup schedule, it can cause the policy to stop before completion (for example, 60).

enabled

Boolean

Indicates if the cleanup policy is active (true) or disabled (false).

A cleanup policy must be created inactive. This parameter is optional, but if used it must be set to false. If set to true when calling this API, the API call will fail and an error message is received.

Note

After a cleanup policy is created, it can be set to active by calling Enable/Disable Build Cleanup Policy API.

deleteArtifacts

Boolean

Deletes the artifacts associated with the build (true to delete).

skipTrashcan

string

true value means that when this policy is executed, builds will be permanently deleted. false means that when the policy is executed builds will be deleted to the Trash Can.

Note

The Global Trash Can setting must be enabled if you want deleted items to be transferred to the Trash Can.

searchCriteria

Object

An object containing search criteria for the cleanup job.

includeAllProjects

Boolean

Specifies whether to include all projects in the search (true to include).

includedProjects

Array of Strings

A list of specific project keys to include in the search ().

includedBuilds

Array of Objects

Builds to consider during cleanup.

name

String

The name of the build.

projectKey

String

The project identifier associated with the build. This key is obtained from the Project Settings screen. Leave the field blank to apply at a global level.

excludeBuildsWithReleaseBundles

Boolean

Specifies whether to include builds with release bundles (true to exclude)

createdBeforeInMonths

Integer

Specifies the time frame for filtering based on item creation date (for example, 24 months).

Response Error Codes

Code

Description

400

Validation errors.

500

Internal server error.