关于JFrog Artifactory文件版本管理机制的咨询
Hey Christoph, great question—let's break this down clearly since Artifactory's versioning model is a bit different from the source control systems you're familiar with!
Why Your Old Version Disappeared
By default, Artifactory uses an overwrite mode for generic file deployments. That means if you upload a file to the exact same path (e.g., generic-local/myfile.txt) multiple times, each new upload replaces the existing one. No automatic version history is kept unless you explicitly configure it—this is why your old version seemed to vanish after re-deploying the modified file.
How to Retain Versions Without Changing Filenames
You don't have to embed version numbers in filenames to track history. Here are the most effective ways to set up versioning for generic files:
1. Enable Version Retention in Your Repository Configuration
For generic repositories (the best fit for non-package files), you can turn on automatic version retention:
- Go to your repository's settings in Artifactory
- Navigate to the Versioning or Advanced tab (depending on your Artifactory version)
- Look for settings like:
- Retain Old Versions: Toggle this on, then set a maximum number of old versions to keep (e.g., 5)
- Unique Snapshots: If you're working with "snapshot"-style files, this ensures each upload gets a unique identifier while keeping the base filename
Once enabled, every time you upload a new version to the same path, Artifactory will archive the old version instead of overwriting it. You can view and restore these versions from the file's History tab in the Artifactory UI.
2. Use Custom Properties to Tag Versions
Another flexible approach is to attach version metadata directly to files using properties. This lets you track versions without changing paths or filenames:
- When uploading via the CLI, add the
--propsflag to tag your file:# Upload version 1.0 of your file jf rt upload myfile.txt generic-local/myfile.txt --props "version=1.0" # After modifying, upload version 1.1 jf rt upload myfile.txt generic-local/myfile.txt --props "version=1.1" - In the Artifactory UI, you can filter files by the
versionproperty to find specific releases, or view all versions of a file by checking its properties and history.
3. Path-Based Versioning (Manual but Intuitive)
If you prefer a more hands-on approach (similar to how you might organize versions in source control), you can structure your upload paths to include version numbers:
- Upload v1.0 to
generic-local/myapp/1.0/myfile.txt - Upload v1.1 to
generic-local/myapp/1.1/myfile.txt
This method makes versioning explicit and easy to navigate, but requires you to manage the path structure manually during uploads.
How This Compares to Package Versioning
For software packages (like Maven, npm, or Docker), Artifactory automatically recognizes built-in version fields and retains all versions by default. For generic files, you just need to replicate that behavior using the configuration or property methods above—no special package structure required.
Quick Tip: Viewing Old Versions
Once you've set up version retention, go to the file's detail page in Artifactory. Look for the History tab—this will show you all archived versions, with options to download, restore, or delete specific releases.
内容的提问来源于stack exchange,提问作者Christoph

