gpt4 book ai didi

java - Jenkins 不可读的 POM

转载 作者:太空宇宙 更新时间:2023-11-04 10:33:44 25 4
gpt4 key购买 nike

此错误甚至发布在不同的论坛中 here 。我尝试过不同的选择。我尝试更改 POM 权限。我正在使用默认的 Maven 设置。 JDK是8,Maven 3.5.3。

我只想尝试一个非常简单的 junit 应用程序。从命令行我运行“mvn test”没有问题

junitexample amh$ mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.junit:junit-example >-----------------------
[INFO] Building junit-example 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ junit-example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ junit-example ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ junit-example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/amhg/Documents/dev/intellik2/junitexample/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ junit-example ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ junit-example ---
[INFO] Surefire report directory: /Users/amhg/Documents/dev/intellik2/junitexample/target/surefire-reports

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running CalculatorTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.045 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.178 s
[INFO] Finished at: 2018-04-08T01:39:52+02:00
[INFO] ------------------------------------------------------------------------

但是从 Jenkins ,从控制台输出我有这个错误:

控制台输出

Started by user Andrea
Building in workspace /Users/Shared/Jenkins/Home/workspace/calc
[calc] $ /Users/amhg/apache-maven-3.5.3/bin/mvn -f /Users/amhg/Documents/dev/intellik2/junitexample test
POM file /Users/amhg/Documents/dev/intellik2/junitexample specified with the -f/--file command line argument does not exist
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-readable POM /Users/amhg/Documents/dev/intellik2/junitexample: /Users/amhg/Documents/dev/intellik2/junitexample (Permission denied) @
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project (/Users/amhg/Documents/dev/intellik2/junitexample) has 1 error
[ERROR] Non-readable POM /Users/amhg/Documents/dev/intellik2/junitexample: /Users/amhg/Documents/dev/intellik2/junitexample (Permission denied)
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

这是我的 POM 文件

<?xml version="1.0" encoding="UTF-8"?>
<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>com.junit</groupId>
<artifactId>junit-example</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>junit-example</name>
<url>http://maven.apache.org</url>


<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>

我只是做了一个简单的测试:

import org.junit.BeforeClass;
import org.junit.Test;

import static junit.framework.TestCase.assertEquals;

public class CalculatorTest {
private static ICalculator calculator;

@BeforeClass
public static void initCalculator() {
calculator = new Calculator();

}

@Test
public void testSum() {
int result = calculator.sum(3, 4);
assertEquals(7, result);
}
}

我不知道我还能尝试什么。我打开了所有与该问题相关的主题。

还有其他建议吗?

最佳答案

我遇到了完全相同的问题 - 本地 maven 构建工作正常,而 Jenkins 失败并出现与您相同的错误。

一旦 Jenkins 作业启动,它会将源代码导入到 /your-jenkins/workspace/your-job-name 文件夹中,然后开始构建。在 DSL 中,您必须提及工作区中 pom 的路径。

下载源代码后,查看 Jenkins 工作区 View 以了解您的 pom 所在的位置。这将有助于解决问题。

enter image description here

关于java - Jenkins 不可读的 POM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49713136/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com