我試圖在jenkins上的maven構建完成後將webapp.war複製到tomcat的webapp文件夾中。Maven在Jenkins上構建後將webapp部署到Tomcat
<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>
我加入了詹金斯用戶到tomcat組
$ id -Gn jenkins
jenkins tomcat
和我的web應用文件夾權限的樣子
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
應該不是很足夠了詹金斯用戶是其成員的tomcat組,並且這個組擁有webapps文件夾的寫權限?
THX,科皮
行家戰爭插件做同樣的以下鏈接。結帳https://stackoverflow.com/questions/369639/maven-copy-war-to-tomcats-webapps-directory – Vaibs
謝謝你的建議,Vaibs。我會牢記這一點。現在,我更喜歡部署到容器插件。 –