I have a folder structure as Backup/Date/hostname/*zip. I want to delete the folder date which has 7 days prior date than current. I am using below command:
curl -k -u user:pass -X DELETE https://artifactory.test.com/artifactory/Backup/$Date.
But it is deleting the entire Backup
artifact from artifactory
.
It is to be done by curl, or any other means, but not through jfrog cli because I have to run this in jenkins
.
How can this be resolved?
Assuming your date format is ddmmyyyy
, try
DATE=$(date --date="7 days ago" +%d%m%Y)
curl -k -u user:pass -X DELETE https://artifactory.test.com/artifactory/Backup/${DATE}
Edit: If from Jenkins, do as below.
withCredentials([usernamePassword(credentialsId: '<your-credsID>', passwordVariable: 'pass', usernameVariable: 'user')]) {
sh '''
DATE=$(date --date="7 days ago" +%d%m%Y)
curl -k -u $user:$pass -X DELETE https://artifactory.test.com/artifactory/Backup/${DATE}
'''
}