I have been trying to automate workspace cleanup in jenkins, in which we need to retain the content upto certain number of days, lets say 'x', and need to delete the content older than x days.
I wrote a pipeline, which was rejected by unix team as they don't want to use rm -f INSTEAD they want to use cleanWS in the pipeline. The plugin is already installed in jenkins. Please suggest how can I use this plugin in the declarative pipeline to obtain the desired output. Jenkins version - 2.289.3
The pipeline which I wrote earlier, is as below:
Pipeline{
agent{
label "${params.agent}"
}
stages{
stage('workspace cleanup'){
steps{
script{
sh "find /jenkins/${params.folder} -mtime +${params.days} -exec rm -f {} \;"
}
}
}
}
}