DISTRIBUTION: How to create a Release Bundle with selected files using the REST API command
Subject: Creating a Release Bundle with selected files using the REST API command
Affected Versions: Artifactory 7.x / Distribution 2.x
Description
When creating a Release Bundle from the JFrog Platform UI, it provides an option to select files using property and value pairs.
This article provides step-by-step instructions on how to use the REST API command to create a Release Bundle on JFrog Distribution and select files based on properties.
Step 1: Prepare the JSON Request BodyTo create a Release Bundle with selected files based on a property, you need to construct a JSON request body. Here's an example of the JSON structure:
{
"name": "my-release-bundle",
"version": "1.0",
"sign_immediately": true,
"release_notes": {
"syntax": "plain_text",
"content": "Version 1.0 to create a bundle using the REST API command"
},
"spec": {
"queries": [
{
"aql": "items.find({ \"repo\" : \"example-repo-local\"}, {\"@key\": \"value\"})",
"query_name": "query-1",
"mappings": [
{
"input": "regex",
"output": "$1/$2"
}
]
}
]
}
}Step 2: Specify the Property FilterTo select files based on a specific property, modify the "aql" field in the JSON. Replace the "@key":"value" placeholder with the actual property and its corresponding value. For example, if you want to filter files based on a property called "version" with a value of "1.0", the "aql" line would be
"aql": "items.find({ \"repo\" : \"example-repo-local\"}, {\"@version\": \"1.0\"})"Step 3: Send the REST API RequestFrom the terminal, send a POST request to the following endpoint: /api/v1/release_bundle. Include the JSON request body created in the previous steps as the payload of the request.
curl -u <USER> -H "Content-Type: application/json" -H "X-GPG-PASSPHRASE: <PASSPHRASE>" -X POST http://<ARTIFACTORY_URL>/distribution/api/v1/release_bundle -T bundle.json
Step 4: Verify the Release Bundle
Upon successfully creating the release bundle, you can verify its existence in JFrog Distribution UI or by making a GET request to the /api/v1/release_bundle/{name}/{version} endpoint, replacing {name} and {version} with the actual values of your release bundle.
$ curl -u <USER> http://<ARTIFACTORY_URL>/distribution/api/v1/release_bundle/my-release-bundle/1.0
{
"name": "my-release-bundle",
"version": "1.0",
"storing_repository": "release-bundles",
"release_notes": {
"content": "Version 1.0 to create the bundle using the API command",
"syntax": "plain_text"
},
"created": "2023-06-12T18:35:22.559+0000",
"created_by": "admin",
"artifacts": [
{
"checksum": "900cb144c8b6992267af8b133d22af3e060b12cd3051473d5aa20f93dc0de2a2",
"props": [{ "key": "version", "values": ["1.0"] }],
"sourceRepoPath": "release-bundles/my-release-bundle/1.0/example-repo-local/artifactory-access-config.yaml",
"targetRepoPath": "example-repo-local/artifactory-access-config.yaml"
}
],
"artifacts_size": 492,
"archived": false,
"state": "READY_FOR_DISTRIBUTION",
"xray_triggering_status": "NOT_TRIGGERED",
"spec": {
"queries": [
{
"aql": "items.find({ \"repo\" : \"example-repo-local\"}, {\"@version\": \"1.0\"})",
"query_name": "query-1",
"mappings": [{ "input": "regex", "output": "$1/$2" }],
"added_props": [],
"exclude_props_patterns": [],
"query_type": "AQL"
}
]
}
}