The “ARTIFACTORY: How to create a Release Bundle V2” article explains how to create a Release Bundle V2.
In this article, I will explain how to distribute a Release Bundle V2 using REST API.
Assuming that a Release Bundle V2 is created using the below payload:
❯ curl --location 'http://[ARTIFACTORY_URL]/lifecycle/api/v2/release_bundle?project=default&async=false' --header 'X-JFrog-Signing-Key-Name: my-gpg-key' --header 'Content-Type: application/json' --header 'Authorization: Bearer [ACCESS_TOKEN]' --data '{
"release_bundle_name": "rbv2-rest-api",
"release_bundle_version": "1",
"source_type": "artifacts",
"source": {
"artifacts": [
{
"path": "source-local-repo/awx-2.3.1.tar",
"sha256": "65a5ebf84c147f0ae54e638b6df447d11586f8e7b2619fbac39fbe1d0623933d"
}
]
}
}' We can use the Distribute Release Bundle Version v2 REST API below to distribute the release bundle (here, my release bundle name is ‘rbv2-rest-api’ and the version is ‘1’):
❯ curl --location 'http://[ARTIFACTORY_URL]/lifecycle/api/v2/distribution/distribute/rbv2-rest-api/1' --header 'Content-Type: application/json' --header 'Authorization: Bearer [ACCESS_TOKEN]' --data '{
"auto_create_missing_repositories": "false",
"distribution_rules": [
{
"site_name": "*"
}
]
}'
{"id":879116862733533184,"sites":[{"name":"edge","service_id":"jfrt@01j5vhn5b7xp0y1m2f7j2r018j","type":"artifactory"}]}
I can see from my edge node that the package awx-2.3.1.tar is created in the repository “source-local-repo”.
If we wish to distribute a package to a different repository on target, we can use mappings like below:
❯ curl --location 'http://[ARTIFACTORY_URL]/lifecycle/api/v2/distribution/distribute/rbv2-rest-api-repo/1' --header 'Content-Type: application/json' --header 'Authorization: Bearer [ACCESS_TOKEN]' --data '{
"auto_create_missing_repositories": "false",
"distribution_rules": [
{
"site_name": "*"
}
],
"modifications": {
"defaultPathMappingByLastPromotion": true,
"mappings": [
{
"input": "source-local-repo/(.*)",
"output": "target-local-repo/$1"
}
]
}
}'
{"id":879118628858478592,"sites":[{"name":"edge","service_id":"jfrt@01j5vhn5b7xp0y1m2f7j2r018j","type":"artifactory"}]}
I can see that the package is deployed to “target-local-repo” on my target edge node.