glassfishasadmin

Deploy to remote Glassfish instance via cli


I am trying to automatically deploy our Java EE application from our build server (Jenkins) to a remote Glassfish server via the command line. At the moment I am using asadmin for this and it works fine, but this option requires me to have Glassfish installed on the build server as well - which I would like to avoid as I do not need it there. The build server is really only running the builds and the deployment so I would like to keep the server as "clean" as possible.

I can't find any download that installs only the asadmin tools, and also my attempt to manually copy over only the required files failed as there are some dependencies to certain *.jars that I don't know of so it always fails unless I copy the whole glassfish installation folder to the build server.

So my question is: Does anybody know how to install only the asadmin tools without installing the whole Glassfish server? Alternatively I would also be happy to use any other command line tools as long as they allow me to deploy to a remote Glassfish instance using secure communication.


Solution

  • After doing a bit more research I gave up on trying to install asadmin without the full Glassfish installation and instead used Glassfish's REST admin interface.

    I now made it work using CURL in a simple batch file:

    curl.exe ^
        --user glassfish_username:glassfish_password ^
        --insecure ^
        -H "Accept: application/json" ^
        -H "X-Requested-By: dummy" ^
        -X POST ^
        -F id=@yourfile.war ^
        -F contextroot=yourcontextroot ^
        -F force=true ^
        https://yourservername:4848/management/domain/applications/application/
    

    The REST API is fairly straight forward once you know what you need to do but just in case somebody else needs this, here a couple of important points: