-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
formatting question - KeepLatestVersionNFilesInFolder #83
Comments
Hi! Have you tried to escape - rule: KeepLatestVersionNFilesInFolder
count: 1
custom_regexp: "[^\\d][\\._]((\\d+\\.)+\\d+)" Could you give few examples for the filenames? I need to reproduce it on my side, don't get the filename format from the regexp |
Do you use RPM repository or it's just usual file one with rpm files in it? |
Sorry, yes, I ran into the double escape issue, & have since updated the regexp: - rule: KeepLatestVersionNFilesInFolder
count: 2
custom_regexp: "bootstrap-gui-([\\d]+\\.[\\d]+\\-[\\d]+).*\\.rpm"
- rule: KeepLatestVersionNFilesInFolder
count: 2
custom_regexp: "bootstrap-influxdb-([\\d]+\\.[\\d]+\\-[\\d]+).*\\.rpm"
- rule: KeepLatestVersionNFilesInFolder
count: 2
custom_regexp: "bootstrap-ingest-([\\d]+\\.[\\d]+\\-[\\d]+).*\\.rpm" The repositories are "package type: RPM," & examples of the files above are:
As you can see, the revision is delineated by a |
@t-readyroc thank you for pointing out the exact line! I've pushed the fix for it here #84
Important note - above rules don't work in that way If you use In order to achieve what you want - you have to split it to different policies policies:
- name: reponame - bootstrap gui
rules:
- rule: Repo
name: "reponame"
- rule: KeepLatestVersionNFilesInFolder
count: 2
custom_regexp: "bootstrap-gui-([\\d]+\\.[\\d]+\\-[\\d]+).*\\.rpm"
- name: reponame - bootstrap ingest
rules:
- rule: Repo
name: "reponame"
- rule: KeepLatestVersionNFilesInFolder
count: 2
custom_regexp: "bootstrap-ingest-([\\d]+\\.[\\d]+\\-[\\d]+).*\\.rpm"
|
Hey @allburov - running into an odd thing. Getting the following error: Traceback (most recent call last):
File "/home/myuser/.pyenv/versions/ans2.10/bin/artifactory-cleanup", line 33, in <module>
sys.exit(load_entry_point('artifactory-cleanup==1.0.4', 'console_scripts', 'artifactory-cleanup')())
File "/home/myuser/.pyenv/versions/3.8.13/envs/ans2.10/lib/python3.8/site-packages/plumbum/cli/application.py", line 177, in __new__
return cls.run()
File "/home/myuser/.pyenv/versions/3.8.13/envs/ans2.10/lib/python3.8/site-packages/plumbum/cli/application.py", line 634, in run
retcode = inst.main(*tailargs)
File "/home/myuser/.pyenv/versions/3.8.13/envs/ans2.10/lib/python3.8/site-packages/artifactory_cleanup/cli.py", line 121, in main
for summary in cleanup.cleanup(
File "/home/myuser/.pyenv/versions/3.8.13/envs/ans2.10/lib/python3.8/site-packages/artifactory_cleanup/artifactorycleanup.py", line 53, in cleanup
artifacts_to_remove = policy.filter(artifacts)
File "/home/myuser/.pyenv/versions/3.8.13/envs/ans2.10/lib/python3.8/site-packages/artifactory_cleanup/rules/base.py", line 284, in filter
artifacts = rule.filter(artifacts)
File "/home/myuser/.pyenv/versions/3.8.13/envs/ans2.10/lib/python3.8/site-packages/artifactory_cleanup/rules/keep.py", line 176, in filter
artifactory_with_version.sort()
TypeError: '<' not supported between instances of 'dict' and 'dict' Running 1.0.4:
Also: thanks for the heads-up on the rules formatting. I'm now formatting them as separate policies, like so: - name: bootstrap-repo-* - Keep 2 most recent versions - bootstrap-gui
rules:
- rule: RepoByMask
mask: "bootstrap-repo-*"
- rule: IncludePath
masks: "Packages"
- rule: KeepLatestVersionNFilesInFolder
count: 2
custom_regexp: "bootstrap-gui-([\\d]+\\.[\\d]+\\-[\\d]+).*\\.rpm"
- name: bootstrap-repo-* - Keep 2 most recent versions - bootstrap-ingest
rules:
- rule: RepoByMask
mask: "bootstrap-repo-*"
- rule: IncludePath
masks: "Packages"
- rule: KeepLatestVersionNFilesInFolder
count: 2
custom_regexp: "bootstrap-ingest-([\\d]+\\.[\\d]+\\-[\\d]+).*\\.rpm" |
@t-readyroc I've pushed new version to the same branch Make sure to uninstall it before install the updated version pip uninstall artifactory-cleanup
pip install git+https://github.com/devopshq/artifactory-cleanup.git@keep-latest-n-files-no-dot
artifactory-cleanup --version
# Must show 1.0.4 |
@allburov - looks like your last update fixed the error! I think what's currently in your branch is going to work for us 😄 |
I may have spoken too soon - but I think we may be back to a question of rule formatting/use. At the moment, it looks like The following rules are deleting all artifacts from the specified repos. Have I messed up the rule formatting again? A pair of example rules (one for .noarch.rpm, one for .src.rpm): - name: REPO-* - Keep 2 most recent versions - bootstrap-ingest.noarch
rules:
- rule: RepoByMask
mask: "REPO-*"
- rule: IncludePath
masks: "Packages"
- rule: KeepLatestVersionNFilesInFolder
count: 2
custom_regexp: "bootstrap-ingest-([\\d]+\\.[\\d]+\\-[\\d]+)\\.noarch\\.rpm"
- name: REPO-* - Keep 2 most recent versions - bootstrap-ingest.src
rules:
- rule: RepoByMask
mask: "REPO-*"
- rule: IncludePath
masks: "Packages"
- rule: KeepLatestVersionNFilesInFolder
count: 2
custom_regexp: "bootstrap-ingest-([\\d]+\\.[\\d]+\\-[\\d]+)\\.src\\.rpm" I've just run a test output (no |
Example output from the application on one of the above rules. 3.10-90 & 3.10-92 are the most recent 2 versions:
|
Any ideas on this? |
@allburov have you considered comparing versions via packaging? In my other project, he worked out correctly with a dash ("-"), but I just don't have enough experience to change something correctly here) |
Actually, the version pattern depends on repository type a lot - debian's repository can have a bit different version pattern than python one, for instance. |
@allburov Can you explain why such a regular expression does not work in the project? Gives out such an error? I tried both in the release and in the branch from this issue the same way
UPD: |
I have a similar issue, my version pattern looks like 24.1.3-7698, so the Is there a planned fix for this or should I create a custom rule? BTW, replacing the
With
Should do the trick, I don't mind creating a PR if you are intrested |
I'm wondering if I may not be able to use this tool due to our versioning scheme. Each repo has a "Packages" subfolder that I'm including, but then also has 30+ different file names in each. I've written the equivalent number of rules for each repo, e.g.:
etc & so forth, to cover each of the different file names. However, when I attempt to run the cleanup, the script gives me the error:
I have tested each individual regex, to make sure that they do match the version numbers for each file name. I'm pretty sure I'm just not formatting it correctly for what the script expects. I'm guessing that maybe the rule separates the digits by dots? Which won't work for us, since our last digit is separated by a dash?
Any guidance would be appreciated.
The text was updated successfully, but these errors were encountered: