我试图用Jenkins建立maven战争项目。
Jenkins提取代码并构建项目。但是,构建不在工作区中,而是在具有项目源的文件夹中。我认为Jenkins从maven pom文件中获取目标文件夹并构建它。
如何调整Jenkins以构建和部署管道?
在部署阶段,Jenkins无法找到war文件。
操作系统是Windows,IDE - eclipse。
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.test.webapp</groupId>
<artifactId>webApp</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>webApp</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>8.0.5</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<directory>${basedir}\target</directory> <!-- tried with this line and without -->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
答案 0 :(得分:0)
我应对问题的方式: 在pom.xml中:
<properties>
<baseFolder>${basedir}</baseFolder>
</properties>
<build>
<directory>${baseFolder}/target</directory>
</directory>
在Jenkins中运行带有属性的构建maven构建
baseFolder=$WORKSPACE