我在Jenkins工作,我想向Nexus发布一件神器。它在执行期间抱怨mavne-compiler-plugin和maven-release-plugin。关于问题是什么以及如何解决它的任何想法?
在Jenkins工作中,我还检查了Delete workspace before build starts
并将Check out to specific local branch
设置为'master'
这是maven命令
mvn release:clean release:prepare release:perform -DreleaseVersion=${releaseVersion} -DdevelopmentVersion=${developmentVersion} -X
,错误看起来像这样
[INFO] [INFO] -------------------------------------------------------------
[INFO] [ERROR] COMPILATION ERROR :
[INFO] [INFO] -------------------------------------------------------------
[INFO] [ERROR] /var/lib/jenkins/workspace/Release-to-Nexus/target/checkout/src/main/java/com/company/security/jwt/JWTFilter.java:[19,8] cannot access javax.servlet.Filter
[INFO] class file for javax.servlet.Filter not found
...
...
...
[INFO] [INFO] BUILD FAILURE
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 5.919 s
[INFO] [INFO] Finished at: 2018-01-23T17:31:40+00:00
[INFO] [INFO] Final Memory: 41M/361M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project testrepo: Compilation failure: Compilation failure:
[INFO] [ERROR] /var/lib/jenkins/workspace/Release-to-Nexus/target/checkout/src/main/java/com/company/security/jwt/JWTFilter.java:[19,8] cannot access javax.servlet.Filter
[INFO] [ERROR] class file for javax.servlet.Filter not found
...
...
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:16 min
[INFO] Finished at: 2018-01-23T17:31:41+00:00
[INFO] Final Memory: 15M/217M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:perform (default-cli) on project testrepo: Maven execution failed, exit code: '1' -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:perform (default-cli) on project testrepo: Maven execution failed, exit code: '1'
来自pom.xml
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<releaseProfiles>releases</releaseProfiles>
</configuration>
</plugin>
...
<profile>
<id>releases</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>nexus-releases</serverId>
<nexusUrl>https://nexus.url/</nexusUrl>
<skipStaging>true</skipStaging>
</configuration>
</plugin>
</plugins>
</build>
</profile>
java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
javac -version
javac 1.8.0_151
mvn -version
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "4.4.0-109-generic", arch: "amd64", family: "unix"
lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
答案 0 :(得分:0)
The error is raised by the maven-compiler-plugin, so it has to do with compilation. In fact, the error is a simple compilation error due to a "symbol not found" in code.
You should add this dependency to your pom:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
And with this specific library, it is a good idea to set it also with scope=provided
.