Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Script to remove all resources and cloud profiles older than 7 days #4210

hqrt ·

We have scenario in which we have to create cloud profiles and resources to do testing of newly created docker images.

In this process every push to the repo creates new profile and resource and there are many of them. We want to make them removed automatically after few days. How it can be make? Is there any API request which will make it possible?

To make it easier every resource and CP have the same name like: registry.xxx.com/qba/<image_name>: -<build_version>. Can we do search them and remove using regex?

Thank you.

  • replies 1
  • views 54
  • stars 1
robinshen ADMIN ·

Yes, you may create a maintenance configuration running below groovy script periodically:

groovy:
import com.pmease.quickbuild.entitymanager.*

for (cloudProfile in CloudProfileManager.instance.getAll()) {
  if (cloudProfile.name matches some pattern)
    CloudProfileManager.instance.delete(cloudProfile)
}
for (resource in ResourceManager.instance.getAll()) {
  if (resource.name matches some pattern)
     ResourceManager.instance.delete(resource)
}