Search code examples
httpwildflywarwildfly-10undeploy

How to undeploy multiple WARs with single HTTP management API query in WildFly?


I undeploy a WAR using HTTP management API of Wildfly 10 the following way:

curl --digest -u admin:admin -L -H 'Content-Type: application/json'        \
      -d '{"address":[{"deployment":"my-war.war"}],"operation":"remove"}'  \
      http://localhost:9990/management

How to undeploy more than one WAR using one Wildfly HTTP management API request?

I can't find the solution in official docs: https://docs.jboss.org/author/WFLY10/The+HTTP+management+API https://docs.jboss.org/author/WFLY10/Application+deployment

I'm looking for JSON that can undeploy multiple WARs. I've tried some ways with JSON arrays, but to no avail. Some of them result in 500 - Internal Server Error, others fail with WFLYCTL0030 code.


Solution

  • Found it in the EAP 6.4 documentation

    curl --digest -L -D - http://localhost:9990/management --header "Content-Type: application/json" -d '
    {
       "operation":"composite",
       "address":[  
       ],
       "steps":[
          {
             "operation":"undeploy",
             "address":{
                "deployment":"my-war.war"
             }
          },
          {
             "operation":"remove",
             "address":{
                "deployment":"my-war.war"
             }
          },
          {
             "operation":"undeploy",
             "address":{  
                "deployment":"my-second-war.war"
             }
          },
          {
             "operation":"remove",
             "address":{
                "deployment":"my-second-war.war"
             }
          }
       ],
       "json.pretty":1
    }' -u admin:admin