JFrog Artifactory 4.12.2:上传工件时能否同步设置属性?
Hey there! Great question—let's break down how this works in Artifactory 4.12.2, since it's an older version with specific limitations compared to newer releases.
Short Answer
In Artifactory 4.12.2, you cannot set properties at the same time as uploading an artifact—you have to split this into two separate API calls: first upload the file, then apply its properties.
Why This Is the Case
The artifact upload endpoint (typically a PUT request to your target repository path) in 4.12.2 doesn't support attaching properties directly via request parameters, headers, or request body. Property management is handled exclusively by the dedicated Set Properties API endpoint in this version.
Step-by-Step Example
Here's how to do this properly with curl (adjust URLs, credentials, and paths to match your setup):
First, upload your
file.txtartifact:curl -u your-username:your-password -X PUT "http://your-artifactory-instance/artifactory/your-repo/path/to/file.txt" -T "./file.txt"Then, set the properties for the uploaded file:
curl -u your-username:your-password -X PUT "http://your-artifactory-instance/artifactory/api/storage/your-repo/path/to/file.txt" \ -H "Content-Type: application/json" \ -d '{ "properties": { "project": ["my-project"], "environment": ["staging"], "version": ["1.0.0"] } }'
Quick Note for Future Reference
If you ever upgrade to a newer Artifactory version (5.x or later), you can simplify this to a single call using the properties query parameter. For example:
curl -u your-username:your-password -X PUT "http://your-artifactory-instance/artifactory/your-repo/path/to/file.txt?properties=project=my-project;environment=staging" -T "./file.txt"
But this won't work in 4.12.2, so stick to the two-step process for your current version.
内容的提问来源于stack exchange,提问作者Daniel

