簡體   English   中英

發布時,jenkins上的Maven編譯失敗:執行

[英]maven compilation failure on jenkins while release:perform

我在Jenkins工作,我想在Nexus上發布工件。 它抱怨表演期間的mavne-compiler-plugin和maven-release-plugin。 關於問題是什么以及如何解決的任何想法?

在Jenkins作業中,我還檢查了Delete workspace before build startsDelete workspace before build starts並添加了Check out to specific local branch設置為'master'的Check out to specific local branch

這是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

該錯誤是由maven-compiler-plugin引起的,因此它與編制有關 實際上,該錯誤是由於代碼中的“未找到符號”而引起的簡單編譯錯誤。

您應該將此依賴項添加到pom中:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
</dependency>

對於這個特定的庫,最好將其設置為scope=provided

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM