I'm learning Jenkins these days and I faced a situation. I need to execute conditional undeploy
on glassfish. I want to undeploy an application only if it exsits in the server. Is there a way to do this in a single command line?
To do so, I used the followin Bash code:
apps=`asadmin list-applications -t --user=admin --passwordfile=password.txt`
for app in $apps
do
if [ $app = "the_name_of_your_app" ]
then
asadmin --user=admin --passwordfile=password.txt undeploy the_name_of_your_app
fi
done;
PS: the content of password.txt is a single line: AS_ADMIN_PASSWORD=admin
I hope it will help someone someday =)