Deploy a remote instance of Glassfish 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. Right now I'm using asadmin for this and it works great, but for this option I need to install Glassfish on the build server, which I would like to avoid because I don't need it. The build server actually only works with builds and deployments, so I want the server to be as clean as possible.

I can’t find any download that installs only the asadmin tools, as well as my attempt to manually copy only the necessary files, as there are some dependencies on certain * .jars that I don’t know, so it always fails if I don’t copy the whole installation folder for glass fish on the assembly server.

So my question is: Does anyone know how to install only asadmin tools without installing the entire Glassfish server? As an alternative, I would also be happy to use any other command line tools if they allow me to deploy Glassfish to a remote instance using a secure connection.

+4
source share
1 answer

After a little research, I refused to install asadmin without installing Glassfish completely and instead used the Glassfish REST administrative interface.

Now I worked with 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 pretty straight forward, as soon as you know what you need to do, but in case someone needs it, here are a few important points:

  • - Insecure (CURL) to allow self-signed and untrusted SSL certificates
  • The header attributes for "Accept" and "X-Requested-By" must be set, otherwise Glassfish does not process the request and simply returns an empty document as ansower. I don’t know why, but setting these parameters made it work.
  • The content of the war file is passed as the id parameter to POST
  • The URL should be exactly as shown in the text above, i.e. Do not replace the “domain” with your domain name or “application” with your application name. This is the actual endpoint of the REST interface. There is no need to specify the domain / application name anywhere.
+2
source

Source: https://habr.com/ru/post/1436478/


All Articles