我有一个构建Maven项目的Hudson构建作业,并将生成的工件重新部署到Nexus和远程Weblogic实例进行测试。我正在尝试创建一个单独的作业,将相同的工件部署到另一个Weblogic实例,但这样做不需要重新编译项目并制作新的WAR。这里的基本原理是,这些位已经存在并且在开发环境中进行了测试,并且只有在它通过时才能将它们提升到开发集成环境。这可能吗?
到目前为止,我尝试过: 1)使用现有的POM并在命令行上声明mvn deploy wls:undeploy wls:deploy - 这将项目WAR部署到新环境,但也从头开始构建项目。部署目标还取代了Nexus中先前构建的项目工件(快照),这是有道理的。
2)尝试创建一个新的POM,其中前一个构建中的工件是依赖项,而wls-maven-plugin是唯一声明的插件。运行mvn wls:这里的部署也因为不同的原因而失败。
有没有办法以简洁的方式执行这样的部署,而我却错过了?我是否使用了错误的机制(Maven)?我应该使用像Ant这样的基于过程的语言吗?任何见解将不胜感激。 (如果需要更多信息,请告诉我们!)
编辑:如果构建的工件在目标目录中本地可用,则重新部署成功,并且属性文件引用该位置。根据文档on Oracle's website,该参数可以是本地坐标或GAV坐标。如果我使用GAV坐标直接从Nexus中提取工件然后将其推送到远程Weblogic,我会收到以下Maven错误:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MyWebApp 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- wls-maven-plugin:12.1.1.0:redeploy (default-cli) @ MyWebApp-deploy-DIT ---
[INFO] ++====================================================================++
[INFO] ++ wls-maven-plugin: redeploy ++
[INFO] ++====================================================================++
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.480s
[INFO] Finished at: Wed Mar 20 10:19:22 EDT 2013
[INFO] Final Memory: 4M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.oracle.weblogic:wls-maven-plugin:12.1.1.0:redeploy (default-cli) on project MyWebApp-deploy-DIT: Invalid file. Please provide an existing fully qualified path of the file. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
为了完整起见,我还发布了我用来执行选项#2的POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>MyWebApp</name>
<parent>
<groupId>org.myorg.maven</groupId>
<artifactId>MyOrg-Parent</artifactId>
<version>2.0</version>
</parent>
<groupId>org.myorg.apps</groupId>
<artifactId>MyWebApp-deploy-DIT</artifactId>
<version>0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<drools.version>5.4.0.Final</drools.version>
<REGION>DEV</REGION>
<MyWebApp_LOGDIR>.</MyWebApp_LOGDIR>
<webapp.jsp.dir>src/main/webapp/WEB-INF/jsp</webapp.jsp.dir>
<buildMsgJsp>buildMsg.jsp</buildMsgJsp>
<DEPLOYMENT_NAME>MyWebApp</DEPLOYMENT_NAME>
<MIDDLEWARE_HOME>/ci/oracle/middleware</MIDDLEWARE_HOME>
<WLS_ADMIN_HOST>lncibd008</WLS_ADMIN_HOST>
<WLS_PORT>7001</WLS_PORT>
<STAGE>true</STAGE>
<!--<SOURCE>${project.build.directory}/MyWebApp-3.7-SNAPSHOT.war</SOURCE>-->
<SOURCE>org.myorg.apps:MyWebApp:war:3.7-SNAPSHOT</SOURCE>
<WLS_TARGETS>server1</WLS_TARGETS>
</properties>
<dependencies>
<dependency>
<groupId>org.myorg.apps</groupId>
<artifactId>MyWebApp</artifactId>
<version>3.7-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.oracle.weblogic</groupId>
<artifactId>wls-maven-plugin</artifactId>
<version>12.1.1.0</version>
<configuration>
<weblogicHome>wlserver_12.1</weblogicHome>
<upload>true</upload>
<remote>true</remote>
<stage>${STAGE}</stage>
<verbose>true</verbose>
<userConfigFile>wlsconfig/${WLS_ADMIN_HOST}${WLS_PORT}.config</userConfigFile>
<userKeyFile>wlsconfig/${WLS_ADMIN_HOST}${WLS_PORT}.key</userKeyFile>
<adminurl>http://${WLS_ADMIN_HOST}:${WLS_PORT}</adminurl>
<targets>${WLS_TARGETS}</targets>
<source>${SOURCE}</source>-->
<name>${DEPLOYMENT_NAME}</name>
<middlewareHome>C:\Oracle\Middleware</middlewareHome>
</configuration>
</plugin>
</plugins>
</build>
</project>
正如你所看到的,我有一个评论出来和一个GAV。本地一个成功,GAV因上述错误而失败。