Is their a java api to delete old process deployments?

Hi,

My use case is to query and delete all the old process deployments(cascade) from back-end service. Is their a way to achieve it

Hi @kirankk,

you can use the RepositoryService or the Rest Api to query and delete deployments.

Does this help you?

Best regards,
Philipp

1 Like

Here’s a simple java example for a full deployment cleanup.

List<Deployment> deployments = repositoryService
      .createDeploymentQuery()
      .list();
   
    List<String> deploymentIds = new ArrayList<String>();
    for (Deployment deployment : deployments) {
      deploymentIds.add(deployment.getId());
    } 
   
    LOGGER.info("*** deleteAllDeployments count: " + deploymentIds.size()); 
    
   
   for(String deploymentId :  deploymentIds) {
     repositoryService.deleteDeployment(deploymentId, true);
     
   }

For an evolving set of java utils… github link for above.

Thanks @Philipp_Ossler, @garysamuelson. That helps.
Please let me know if you have any ideas on this. Thanks again

The DeploymentQuery class sounds like a good start. My previous example uses the “fluent” approach. But, for a more detailed view of DeploymentQuery options, you could do something similar to:

javadoc

    DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery();
    // deploymentQuery.<lots of features available here>
    List<Deployment> deploymentsScratch = 
        deploymentQuery
          .deploymentName("myDeployName")
          //.deploymentBefore(<date here>)
          //.etc
          .list();
    

That’s Cool, Thanks @garysamuelson