Jenkins 使用 Deploy to Container 插件部署到 JBoss EAP7

Posted

技术标签:

【中文标题】Jenkins 使用 Deploy to Container 插件部署到 JBoss EAP7【英文标题】:Jenkins deploy to JBoss EAP7 with Deploy to Container plugin 【发布时间】:2021-06-01 04:20:29 【问题描述】:

我已经在单独的服务器上配置了 Jenkins 来构建一个 Maven 项目,现在我希望 Jenkins 通过部署到容器 jenkins 将项目部署到位于不同服务器上的 JBoss EAP(7.3.0) 上(1.16) 插件,但是当我尝试部署时出现以下错误:

15:58:33 [DeployPublisher][INFO] Attempting to deploy 1 war file(s)
15:58:34 ERROR: Build step failed with exception
15:58:34 org.codehaus.cargo.container.ContainerException: Failed to create deployer with implementation class org.codehaus.cargo.container.jboss.JBoss7xRemoteDeployer for the parameters (container [id = [jboss7x]], deployer type [remote]).
15:58:34    at org.codehaus.cargo.generic.spi.AbstractGenericHintFactory.createImplementation(AbstractGenericHintFactory.java:154)
15:58:34    at org.codehaus.cargo.generic.spi.AbstractIntrospectionGenericHintFactory.createImplementation(AbstractIntrospectionGenericHintFactory.java:89)
15:58:34    at org.codehaus.cargo.generic.deployer.DefaultDeployerFactory.createDeployer(DefaultDeployerFactory.java:131)
15:58:34    at org.codehaus.cargo.generic.deployer.DefaultDeployerFactory.createDeployer(DefaultDeployerFactory.java:150)
15:58:34    at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:69)
15:58:34    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:167)
15:58:34    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:136)
15:58:34    at hudson.FilePath.act(FilePath.java:1164)
15:58:34    at hudson.FilePath.act(FilePath.java:1147)
15:58:34    at hudson.plugins.deploy.CargoContainerAdapter.redeployFile(CargoContainerAdapter.java:133)
15:58:34    at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeployFile(PasswordProtectedAdapterCargo.java:95)
15:58:34    at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:113)
15:58:34    at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
15:58:34    at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:80)
15:58:34    at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
15:58:34    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:803)
15:58:34    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:752)
15:58:34    at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1072)
15:58:34    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:697)
15:58:34    at hudson.model.Run.execute(Run.java:1932)
15:58:34    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
15:58:34    at hudson.model.ResourceController.execute(ResourceController.java:97)
15:58:34    at hudson.model.Executor.run(Executor.java:429)
15:58:34 Caused by: java.lang.reflect.InvocationTargetException
15:58:34    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
15:58:34    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
15:58:34    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
15:58:34    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
15:58:34    at org.codehaus.cargo.generic.deployer.DefaultDeployerFactory.createInstance(DefaultDeployerFactory.java:229)
15:58:34    at org.codehaus.cargo.generic.deployer.DefaultDeployerFactory.createInstance(DefaultDeployerFactory.java:40)
15:58:34    at org.codehaus.cargo.generic.spi.AbstractGenericHintFactory.createImplementation(AbstractGenericHintFactory.java:148)
15:58:34    ... 22 more
15:58:34 Caused by: org.codehaus.cargo.util.CargoException: Cannot locate the JBoss connector classes! Make sure the required JBoss JARs (or Maven dependencies) are in CARGO's classpath.
15:58:34 More information on: https://codehaus-cargo.github.io/cargo/JBoss+Remote+Deployer.html
15:58:34    at org.codehaus.cargo.container.jboss.JBoss5xRemoteDeployer.<init>(JBoss5xRemoteDeployer.java:146)
15:58:34    at org.codehaus.cargo.container.jboss.JBoss7xRemoteDeployer.<init>(JBoss7xRemoteDeployer.java:39)
15:58:34    ... 29 more
15:58:34 Caused by: java.lang.ClassNotFoundException: org.jboss.as.controller.client.ModelControllerClient
15:58:34    at jenkins.util.AntClassLoader.findClassInComponents(AntClassLoader.java:1387)
15:58:34    at jenkins.util.AntClassLoader.findClass(AntClassLoader.java:1342)
15:58:34    at jenkins.util.AntClassLoader.loadClass(AntClassLoader.java:1089)
15:58:34    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
15:58:34    at org.codehaus.cargo.container.jboss.JBoss5xRemoteDeployer.<init>(JBoss5xRemoteDeployer.java:141)
15:58:34    ... 30 more
15:58:34 java.lang.reflect.InvocationTargetException
15:58:34    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
15:58:34    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
15:58:34    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
15:58:34    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
15:58:34    at org.codehaus.cargo.generic.deployer.DefaultDeployerFactory.createInstance(DefaultDeployerFactory.java:229)
15:58:34    at org.codehaus.cargo.generic.deployer.DefaultDeployerFactory.createInstance(DefaultDeployerFactory.java:40)
15:58:34    at org.codehaus.cargo.generic.spi.AbstractGenericHintFactory.createImplementation(AbstractGenericHintFactory.java:148)
15:58:34    at org.codehaus.cargo.generic.spi.AbstractIntrospectionGenericHintFactory.createImplementation(AbstractIntrospectionGenericHintFactory.java:89)
15:58:34    at org.codehaus.cargo.generic.deployer.DefaultDeployerFactory.createDeployer(DefaultDeployerFactory.java:131)
15:58:34    at org.codehaus.cargo.generic.deployer.DefaultDeployerFactory.createDeployer(DefaultDeployerFactory.java:150)
15:58:34    at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:69)
15:58:34    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:167)
15:58:34    at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:136)
15:58:34    at hudson.FilePath.act(FilePath.java:1164)
15:58:34    at hudson.FilePath.act(FilePath.java:1147)
15:58:34    at hudson.plugins.deploy.CargoContainerAdapter.redeployFile(CargoContainerAdapter.java:133)
15:58:34    at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeployFile(PasswordProtectedAdapterCargo.java:95)
15:58:34    at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:113)
15:58:34    at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
15:58:34    at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:80)
15:58:34    at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
15:58:34    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:803)
15:58:34    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:752)
15:58:34    at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1072)
15:58:34    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:697)
15:58:34    at hudson.model.Run.execute(Run.java:1932)
15:58:34    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
15:58:34    at hudson.model.ResourceController.execute(ResourceController.java:97)
15:58:34    at hudson.model.Executor.run(Executor.java:429)
15:58:34 Caused by: org.codehaus.cargo.util.CargoException: Cannot locate the JBoss connector classes! Make sure the required JBoss JARs (or Maven dependencies) are in CARGO's classpath.
15:58:34 More information on: https://codehaus-cargo.github.io/cargo/JBoss+Remote+Deployer.html
15:58:34    at org.codehaus.cargo.container.jboss.JBoss5xRemoteDeployer.<init>(JBoss5xRemoteDeployer.java:146)
15:58:34    at org.codehaus.cargo.container.jboss.JBoss7xRemoteDeployer.<init>(JBoss7xRemoteDeployer.java:39)
15:58:34    ... 29 more
15:58:34 Caused by: java.lang.ClassNotFoundException: org.jboss.as.controller.client.ModelControllerClient
15:58:34    at jenkins.util.AntClassLoader.findClassInComponents(AntClassLoader.java:1387)
15:58:34    at jenkins.util.AntClassLoader.findClass(AntClassLoader.java:1342)
15:58:34    at jenkins.util.AntClassLoader.loadClass(AntClassLoader.java:1089)
15:58:34    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
15:58:34    at org.codehaus.cargo.container.jboss.JBoss5xRemoteDeployer.<init>(JBoss5xRemoteDeployer.java:141)
15:58:34    ... 30 more
15:58:34 Build step 'Deploy war/ear to a container' marked build as failure
15:58:34 Finished: FAILURE

如果您阅读它提供的链接,我已尝试将 cargo-maven3-plugin 安装到我的本地 Maven 存储库 (https://mvnrepository.com/artifact/org.codehaus.cargo/cargo-maven3-plugin/1.9.2) 中:https://codehaus-cargo.github.io/cargo/JBoss+Remote+Deployer.html

但是我仍然收到错误,有人知道问题可能是什么吗?

【问题讨论】:

【参考方案1】:

我找到了解决问题的办法。

    复制位于您的 JBoss 实例中的所有 JAR 文件(例如 JBossEAP7.3.1/Modules/*.jar)。我强烈建议使用搜索功能来查找所有内容。

    将 jars 放入“Deploy to Container”(在文件夹结构中命名为 Deploy)本地 jar 存储库(可以在您为 jenkins 实例安装插件的位置找到,即 .jenkins 文件所在的位置)

    重启詹金斯

    部署到容器将不再遇到发布的错误。

不幸的是,我后来遇到了一个新错误(与此无关),这迫使我为了我的目的放弃了这个插件。

【讨论】:

以上是关于Jenkins 使用 Deploy to Container 插件部署到 JBoss EAP7的主要内容,如果未能解决你的问题,请参考以下文章

20170320-Jenkins-Docker to Deploy

持续集成之 Jenkins 通过 Deploy 插件热部署 java 程序

Jenkins常用插件之Deploy Plugin

Docker 服务在 Jenkins 的 deploy-over-SSH 上退出,但手动成功

Jenkins Pipeline replaceAll 和 Deploy

Jenkins部署报weblogic.deploy.api.tools.deployer.DeployerException: Java heap space