如何使用Jenkins在GlassFish 4服务器中部署War文件

时间:2018-09-04 07:24:07

标签: jenkins glassfish-4

我正在使用Jenkins在GlassFish 4服务器中部署War文件,但是无法部署 Glassfish 4服务器中的war文件。
我正在下面的过程。

enter image description here

但是在构建时会出现以下错误。

  

错误:构建步骤失败,出现异常   org.codehaus.cargo.util.CargoException:无法创建   DeploymentManager位于   org.codehaus.cargo.container.spi.deployer.AbstractJsr88Deployer.getDeploymentManager(AbstractJsr88Deployer.java:356)     在   org.codehaus.cargo.container.spi.deployer.AbstractJsr88Deployer.redeploy(AbstractJsr88Deployer.java:192)     在   hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)     在   hudson.plugins.deploy.CargoContainerAdapter $ DeployCallable.invoke(CargoContainerAdapter.java:147)     在   hudson.plugins.deploy.CargoContainerAdapter $ DeployCallable.invoke(CargoContainerAdapter.java:117)     在hudson.FilePath.act(FilePath.java:1047)处   hudson.FilePath.act(FilePath.java:1025)在   hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)     在   hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)     在   hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)     在hudson.tasks.BuildStepMonitor $ 3.perform(BuildStepMonitor.java:45)     在   hudson.model.AbstractBuild $ AbstractBuildExecution.perform(AbstractBuild.java:744)     在   hudson.model.AbstractBuild $ AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)     在hudson.model.Build $ BuildExecution.post2(Build.java:186)处   hudson.model.AbstractBuild $ AbstractBuildExecution.post(AbstractBuild.java:635)     在hudson.model.Run.execute(Run.java:1819)处   hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)在   hudson.model.ResourceController.execute(ResourceController.java:97)     在hudson.model.Executor.run(Executor.java:429)上,原因如下:   javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException:   无法获取DeploymentManager;没有注册的DeploymentFactory   在以下位置处理此URI   javax.enterprise.deploy.shared.factories.DeploymentFactoryManager.getDeploymentManager(DeploymentFactoryManager.java:117)     在   org.codehaus.cargo.container.glassfish.GlassFish3xRemoteDeployer.getDeploymentManager(GlassFish3xRemoteDeployer.java:82)     在   org.codehaus.cargo.container.spi.deployer.AbstractJsr88Deployer.getDeploymentManager(AbstractJsr88Deployer.java:352)     ...另外18个   javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException:   无法获取DeploymentManager;没有注册的DeploymentFactory   在以下位置处理此URI   javax.enterprise.deploy.shared.factories.DeploymentFactoryManager.getDeploymentManager(DeploymentFactoryManager.java:117)     在   org.codehaus.cargo.container.glassfish.GlassFish3xRemoteDeployer.getDeploymentManager(GlassFish3xRemoteDeployer.java:82)     在   org.codehaus.cargo.container.spi.deployer.AbstractJsr88Deployer.getDeploymentManager(AbstractJsr88Deployer.java:352)     在   org.codehaus.cargo.container.spi.deployer.AbstractJsr88Deployer.redeploy(AbstractJsr88Deployer.java:192)     在   hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)     在   hudson.plugins.deploy.CargoContainerAdapter $ DeployCallable.invoke(CargoContainerAdapter.java:147)     在   hudson.plugins.deploy.CargoContainerAdapter $ DeployCallable.invoke(CargoContainerAdapter.java:117)     在hudson.FilePath.act(FilePath.java:1047)处   hudson.FilePath.act(FilePath.java:1025)在   hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)     在   hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)     在   hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)     在hudson.tasks.BuildStepMonitor $ 3.perform(BuildStepMonitor.java:45)     在   hudson.model.AbstractBuild $ AbstractBuildExecution.perform(AbstractBuild.java:744)     在   hudson.model.AbstractBuild $ AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)     在hudson.model.Build $ BuildExecution.post2(Build.java:186)处   hudson.model.AbstractBuild $ AbstractBuildExecution.post(AbstractBuild.java:635)     在hudson.model.Run.execute(Run.java:1819)处   hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)在   hudson.model.ResourceController.execute(ResourceController.java:97)     在hudson.model.Executor.run(Executor.java:429)构建步骤'部署   战争/对一个容器的耳朵标记为失败的构建完成:FAILURE

3 个答案:

答案 0 :(得分:2)

我可以使用以下两种方法中的任何一种来使Glassfish 4陷入困境:

  1. 方法1使用新版本的Deploy to container Plugin

    您可以从github克隆以下内容(注意:您可以尝试使用新版本的插件)

    https://github.com/jenkinsci/deploy-plugin/tree/205715c3556ade8d8665de677ebb41e35ee64793

    现在构建项目,在目标文件夹中可以找到可以安装在jenkins中的deploy.hpi文件。此版本支持Glassfish 4。

    要手动安装插件:How to install a plugin in Jenkins manually

  2. 方法2在jenkins中添加以下内容作为执行外壳,根据需要更新值并创建glassfish密码文件,它将取消对Ear文件的部署并部署新文件。

#!/bin/bash

# FOR JENKINS

# Update following values as required
GLASSFISH_PASSWORD_FILE_PATH=/home/pwd

ASADMIN_PATH="/home/glassfish4/glassfish/bin/asadmin"
ASADMIN_BASE_CMD="$ASADMIN_PATH --host 10.13.209.100 --port 9048 --user admin2 --passwordfile $GLASSFISH_PASSWORD_FILE_PATH"

DEPLOY_EAR_FILE_PATH="Dummy-project-ear/target"
DEPLOY_EAR_FILE_NAME="Dummy-project-ear-1.0-SNAPSHOT.ear"

UNDEPLOY_EAR_NAME="Dummy-project-ear-1.0-SNAPSHOT"

# Commands

$ASADMIN_BASE_CMD list-applications
$ASADMIN_BASE_CMD undeploy $UNDEPLOY_EAR_NAME
$ASADMIN_BASE_CMD deploy $DEPLOY_EAR_FILE_PATH/$DEPLOY_EAR_FILE_NAME

答案 1 :(得分:1)

将Glassfish主机名更改为127.0.0.1或localhost,这对我有用!

答案 2 :(得分:0)

使用Windows批处理文件的示例

@ECHO OFF 
:: BAT START GLASSFISH 5 SERVER
ECHO ============================
ECHO STOPING GLASSFISH 5
ECHO ============================
tasklist | find /i "java.exe" && taskkill /im java.exe /F || echo process "java.exe" not running.
ECHO ============================
ECHO NETWORK INFO
ECHO ============================
ipconfig | findstr IPv4
ECHO ============================
ECHO STARTING GLASSFISH 5
ECHO ============================
ECHO Please wait...
ping 127.0.0.1 -n 10 > nul
net start domain1
ECHO Please wait... Restarting Server
ping 127.0.0.1 -n 90 > nul
exit  0

运行批处理文件:

asadmin --echo=true --host=localhost --port=4848 --user=admin --passwordfile=C:\FilePassGF\passwordfile.txt --secure=false deploy --name "NameWar" --contextroot "NameWar" --force=true "C:\Jenkinshome\deploys\$JOB_NAME\$BUILD_NUMBER\Target-1.0.war"