我试图在jenkins上的maven构建完成后将webapp.war复制到tomcat的webapp文件夹。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>copy-webapp-to-tomcat</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="Deploying webapp to Tomcat.">
<copy todir="${tomcat.webapps.dir}" force="true">
<fileset dir="${project.build.directory}">
<include name="*.war" />
</fileset>
</copy>
</target>
</configuration>
</execution>
</executions>
</plugin>
我将jenkins用户添加到tomcat组
$ id -Gn jenkins
jenkins tomcat
我的webapps文件夹权限看起来像
drwxrwxr-x 10 tomcat tomcat 4,0K Aug 13 17:24 webapps/
构建完成后,复制失败并显示
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (copy-webapp-to-tomcat) on project: An Ant BuildException has occured:
Failed to copy /var/lib/jenkins/workspace/project/target/webapp.war to /opt/tomcat/webapps/webapp.war due to java.io.FileNotFoundException /opt/tomcat/webapps/webapp.war (Permission denied)
[ERROR] around Ant part ...<copy todir="/opt/tomcat/webapps" force="true">... @ 4:50 in /var/lib/jenkins/workspace/project/target/antrun/build-Deploying webapp to Tomcat..xml
当我向webapps文件夹的其他用户添加写权限时
drwxrwxrwx 10 tomcat tomcat 4,0K Aug 13 17:24 webapps/
复制成功,我得到一个文件
-rw-r--r-- 1 jenkins jenkins 22M Aug 13 17:48 webapp.war
jenkins用户是否是tomcat组的成员并且该组具有webapps文件夹的写权限是不够的?
thx,kopi
答案 0 :(得分:2)
请使用复制方法研究war部署插件。它还允许您将来在远程服务器上部署war文件。我已经完成了角度应用的战争部署。
您可以参考以下链接了解更多详情