Skip to content
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

Add new feature Delete Artifacts with pattern #84

Open
wants to merge 111 commits into
base: master
Choose a base branch
from

Conversation

nurgul212
Copy link
Contributor

@nurgul212 nurgul212 commented Jul 21, 2023

Description

A new feature called "Delete artifacts with pattern" has been implemented. This feature allows users to delete build artifacts matching the Ant-style glob patterns, helping them manage their build history more efficiently.

Key Changes

  • Added a new feature called "Delete artifacts with pattern" option to the Build History Manager plugin.
  • Implemented a mechanism to allow users to specify patterns for identifying and deleting artifacts.
  • Added user interface components to facilitate pattern input, including options for specifying both the include and exclude patterns.
  • Updated the documentation to ensure that it includes all the necessary and essential information regarding the new feature.

Test

This new feature is thoroughly tested and ensured its seamless integration with the existing functionality of the Build History Manager plugin.

The custom assert methods have been added to the test class, along with the countFile() method to calculate the file count in a directory. Furthermore, multiple new test cases have been included to examine various include and exclude patterns. These modifications guarantee comprehensive testing of the DeleteArtifactsWithPatternAction class, ensuring its intended functionality while deleting artifacts based on different patterns.

Here are the screenshot of Rule, Include, Exclude Patterns from UI in Jenkins:
image

More examples can be found in README file.
I also have some changes in wiki. They will be shared in #67.

Requesting Feedback and Suggestions for Enhancing the Feature

Please review the changes and provide your feedback. I'm open to any suggestions or improvements that can further enhance the feature.
Thank you for your time and consideration.

Submitter checklist

@nurgul212
Copy link
Contributor Author

Here is the changes in wiki, because Github does not allow to send pull request to the wiki. https://github.com/nurgul212/build-history-manager-plugin-wiki/compare/artifacts-pattern?expand=1

@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7f082df) 99.12% compared to head (9de4746) 99.28%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master      #84      +/-   ##
============================================
+ Coverage     99.12%   99.28%   +0.16%     
- Complexity      123      134      +11     
============================================
  Files            27       29       +2     
  Lines           229      281      +52     
  Branches         18       24       +6     
============================================
+ Hits            227      279      +52     
  Misses            1        1              
  Partials          1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

pom.xml Outdated Show resolved Hide resolved
@nurgul212
Copy link
Contributor Author

Hi Damian, I am pleased to let you know that I've been working on the code coverage of the project and have made substantial improvements. I've added tests to cover previously uncovered or partially covered code lines, and as a result, the code coverage has now reached 100%. All the tests are passing successfully.

I would like to ensure that I've covered everything you may require before approving this pull request. Please let me know if there are any particular tasks or checks you would like me to perform.

Thank you!

pom copy.xml Outdated Show resolved Hide resolved
@damianszczepanik
Copy link
Member

Sonar works fine with new PR https://github.com/jenkinsci/build-history-manager-plugin/actions/runs/5907369801/job/16025196876 so why don't with your PR ?

@olivierdagenais
Copy link
Member

Sonar works fine with new PR https://github.com/jenkinsci/build-history-manager-plugin/actions/runs/5907369801/job/16025196876 so why don't with your PR ?

Looking at https://github.com/jenkinsci/build-history-manager-plugin/actions/workflows/sonarcloud.yml I noticed that all the runs that were successful were from pull requests originating from branches in this repository, whereas those that failed were from pull requests originating from forks.

Given that going to a repository's /settings/secrets/actions URL tells us:

[Secrets and variables] are not passed to workflows that are triggered by a pull request from a fork.

...that would explain the error we get about a missing SONAR_TOKEN, such as:

Error: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project build-history-manager: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator -> [Help 1]

It seems the only way we'll get the sonarcloud action running is if someone pushes this branch's commits to the main repo (not a fork).

.gitignore Outdated Show resolved Hide resolved
@nurgul212
Copy link
Contributor Author

Hi Damian,
Once this pull request is reviewed and approved, we would appreciate it if you could consider releasing the changes at your earliest convenience. Thank you for your time, and we look forward to your feedback and, hopefully, the release of these changes.

Thanks!

@martinda
Copy link
Contributor

@damianszczepanik is more work needed on this pull request? Do you have any concerns?

@damianszczepanik
Copy link
Member

I do have but I do not had time for deeper review. I will

@nurgul212
Copy link
Contributor Author

Here is the changes in wiki, because Github does not allow to send pull request to the wiki. https://github.com/nurgul212/build-history-manager-plugin-wiki/compare/artifacts-pattern?expand=1

@nurgul212
Copy link
Contributor Author

@damianszczepanik I have addressed all the requirements and made the necessary changes. The code is ready for your review.
Thank you!

@nurgul212
Copy link
Contributor Author

nurgul212 commented Nov 2, 2023

@damianszczepanik,
Made necessary changes based on your feedback. But we ran into an issue with the build/build(ubuntu-latest) . It appears that it failed to download some artifacts.
I am not able to queue a rerun because it requires Write permission. Would it be possible for you to rerun the build?
Thanks.

@damianszczepanik
Copy link
Member

If you close and reopen PR it will trigger builds again :)

Nurgul Amat and others added 28 commits December 28, 2023 09:50
Replaced the RuntimeException for failed directory deletion with a log message for better error reporting
…nd remove test coverage

- This commit refactors the code by inlining the 'shouldDelete' and 'shouldDeleteDirectory' methods to simplify the codebase.
- It also removes the associated code coverage tests that are no longer needed after this refactoring.
…model/actions/DeleteArtifactsMatchingPatternsAction.java

Co-authored-by: Olivier "Oli" Dagenais <olivier.dagenais@gmail.com>
…e code and aligned with the feedback that the loop is iterated only once.
…d a method name

- Reorganized the 'deleteFileOrLogError' method to first delete the file and then handle empty directories.
- Renamed 'deleteEmptyDirectoriesAndParenties' method to 'deleteEmptyDirectoryAndParent' as it handles a single directory.
…lass and updated the tests to reflect the changes in the method location
… and refactor 'deleteParentDirectories' method to use 'isArchiveRootDirectory' check for directory traversal
…code readability and understanding of its functionality.
node {

sh '''
rm -rf *
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know what it does but I don't understand why did you add this code here? What is the goal? Are you expecting that someone will copy&paste that code into his pipeline ?

}

for (int i = 1; i <= 5; i++) {
String joined_Artifacts = generateJoinedArtifactsList(runList.get(i-1));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you consider indexing from 0 ?

// CHTAH-1384 scenarios : 1) delete all binaries after 2 days ---> delete everything except the logs after 2 days.
// 2) delete all logs after 5 days ---> delete everything else after 5 days.

public void perform_deleteArtifactsGraduallyOverTime () throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is general Exception needed here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants