0

I have a rather simple deployment script for wildfly 10 cli:

 try
      deploy dummy.war --server-groups=main-server-group
    catch
      deploy dummy.war --force
    end-try

The script is run from a bash script. The problem is that the bash script always returns 1 if the first deploy fails. The deployment in the catch block is executed fine. The return code however breaks the build, so I need a solution for that.

I'd like to build a deployment script which works regardless of the current deployment state of dummy.war.

Any ideas how to make it work?

Thanks!

noidic
  • 23
  • 3

2 Answers2

0

The deploy command is an actual command that executes operations on the server. I don't think the try/catch/finally works on commands, only operations. You could file an issue to support it for try/catch/finally. I'm not sure it's possible however with the way it works.

That said it should be possible with an if/else statement.

if (outcome == success) of /deployment=dummy.war:read-resource
    deploy dummy.war --force
else 
    deploy dummy.war --server-groups=main-server-group
end-if
James R. Perkins
  • 16,800
  • 44
  • 60
0

I solved the problem using two seperate cli commands in one bash script:

jboss-cli.sh --connect --command="undeploy dummy.war --all-relevant-server-groups"

jboss-cli.sh --connect --command="deploy dummy.war --server-groups=main-server-group"

The first command will fail if there is no dummy.war deployed but the exit code of the bash script is 0 if the deploy command succeeds, so my build is happy :)

noidic
  • 23
  • 3