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 environment variables for parameters #125

Merged

Conversation

zhan9san
Copy link
Contributor

@zhan9san zhan9san commented Jan 12, 2024

Fix #124

Here is what I tested.

$ cat artifactory-cleanup-1.yaml
# artifactory-cleanup.yaml
artifactory-cleanup:
  server: https://artifactory.example.com/artifactory
  # $VAR is auto populated from environment variables
  user: $ARTIFACTORY_USERNAME
  password: $ARTIFACTORY_PASSWORD

  policies:
    - name: Remove all files from repo-name-here older than 7 days
      rules:
        - rule: Repo
          name: "test-artifacts-local"
        - rule: DeleteOlderThan
          days: 65535

$ env | grep ARTIFACTORY_CLEANUP
ARTIFACTORY_CLEANUP_CONFIG_FILE=artifactory-cleanup-1.yaml
ARTIFACTORY_CLEANUP_DESTROY=True
$ artifactory-cleanup
********************************************************************************
Destroy MODE
Checking 'test-artifacts-local' repository exists.
The test-artifacts-local repository exists.
Add AQL Filter - rule: Repo - Apply the policy to one repository.
Before AQL query: []
After AQL query: [{'repo': {'$eq': 'test-artifacts-local'}}]

Add AQL Filter - rule: DeleteOlderThan - Deletes artifacts older than `` days`` days
Delete artifacts older than 1844-08-08
Before AQL query: [{'repo': {'$eq': 'test-artifacts-local'}}]
After AQL query: [{'repo': {'$eq': 'test-artifacts-local'}}, {'created': {'$lt': '1844-08-08'}}]

Add AQL Text - rule: Repo - Apply the policy to one repository.
Add AQL Text - rule: DeleteOlderThan - Deletes artifacts older than `` days`` days
********************************************************************************
Result AQL Query:
items.find({"$and": [{"repo": {"$eq": "test-artifacts-local"}}, {"created": {"$lt": "1844-08-08"}}]}).include("*", "property", "stat")
********************************************************************************
Found 0 artifacts
Filter artifacts - rule: Repo - Apply the policy to one repository.
Filter artifacts - rule: DeleteOlderThan - Deletes artifacts older than `` days`` days
Found 0 artifacts AFTER filtering
Deleted artifacts count: 0
Summary size: 0

+--------------------------------------------------------+-------------+------+
| Cleanup Policy                                         | Files count | Size |
+--------------------------------------------------------+-------------+------+
| Remove all files from repo-name-here older than 7 days |      0      |  0B  |
|                                                        |             |      |
| Total size: 0B                                         |             |      |
+--------------------------------------------------------+-------------+------+

Signed-off-by: Jack Zhang <jack4zhang@gmail.com>
@allburov
Copy link
Member

@zhan9san thank you! 👍

@allburov allburov merged commit c2fa03b into devopshq:master Jan 15, 2024
2 checks passed
@zhan9san zhan9san deleted the feature/environment-variable-in-params branch January 15, 2024 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add support for using environment variables to pass parameters
2 participants