通过cli部署到远程Glassfish实例 [英] Deploy to remote Glassfish instance via cli

查看:157
本文介绍了通过cli部署到远程Glassfish实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过命令行将我们的Java EE应用程序从我们的构建服务器(Jenkins)自动部署到远程Glassfish服务器。
此刻我正在使用asadmin,并且它工作正常,但这个选项需要我在生成服务器上安装Glassfish - 我想避免这种情况,因为我不需要它。构建服务器实际上只是运行构建和部署,所以我想尽可能保持服务器干净。



我找不到任何下载只安装asadmin工具,而且我只尝试手动复制所需的文件失败,因为某些* .jars依赖于我不知道的所以它总是失败,除非我将整个glassfish安装文件夹复制到建立服务器。

所以我的问题是:
是否有人知道如何在不安装整个Glassfish服务器的情况下只安装asadmin工具?
另外,我也很乐意使用任何其他命令行工具,只要它们允许我使用安全通信部署到远程Glassfish实例即可。

解决方案

在做了一些更多的研究之后,我放弃了尝试安装asadmin而没有安装完整的Glassfish,而是使用了Glassfish的REST管理界面。



我现在使用CURL在一个简单的批处理文件中工作:

  curl.exe ^ 
--user glassfish_username :glassfish_password ^
--insecure ^
-HAccept:application / json^
-HX-Requested-By:dummy^
-X POST ^
-F id=@yourfile.war ^
-F contextroot = yourcontextroot ^
-F force = true ^
https:// yourservername:4848 / management / domain / applications /应用程序/

一旦您知道您需要做什么,REST API相当直接,但为了以防万一别人需要这些s,这里有几点重要:


  • - 需要不安全(通过CURL)以允许自签名和不可信的SSL证书

  • 必须设置Accept和X-Requested-By的标题属性,否则Glassfish不处理请求并简单地返回空白文档作为ansower。不知道为什么,但设置这些参数使它工作。

  • war
    文件的内容作为POST上的id参数传递
  • URL必须完全按照上面所示的缩略图显示,即不要将域
    替换为您的域名或应用程序与您的应用程序名称。这是实际的REST接口端点。无需在任何地方指定域名/应用程序名称。


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.

解决方案

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:

  • --insecure is required (by CURL) to allow self-signed and untrusted SSL certificates
  • The header attributes for "Accept" and "X-Requested-By" must be set, otherwise Glassfish doesn't process the request and simply returns a blank document as an ansower. No idea why but setting these parameters made it work.
  • The content of the war file is passed as the "id" parameter on the POST
  • The URL needs to be exactly as shown in the snipped above, i.e. do not replace "domain" with your domain name or "application" with your application name. This is the actual REST interface endpoint. There is no need to specify the domain/application name anywhere.

这篇关于通过cli部署到远程Glassfish实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆