java - Azure CI Pipeline 无法使用 2 个项目构建 Java/Maven 解决方案
问题描述
概括:
我从一门课程中学习了一个基本的 Java/Maven 解决方案,并试图让它在 Azure CI 管道中工作。Java 解决方案包含 2 个项目;每个人都有自己的 pom 文件。我能够在 Eclipse 中构建和执行测试。但是,当我尝试在我创建的 Azure CI 管道中使用该解决方案时,它每次都会生成一个错误。
我需要在 Azure 管道文件中进行哪些更改才能正常工作?谢谢。
错误信息:
2020-05-15T15:31:58.1123350Z Downloaded from central: https://repo.maven.apache.org/maven2/junit/junit/4.12/junit-4.12.jar (315 kB at 3.6 MB/s)
2020-05-15T15:31:58.1124631Z [INFO] ------------------------------------------------------------------------
2020-05-15T15:31:58.1125092Z [INFO] BUILD FAILURE
2020-05-15T15:31:58.1125891Z [INFO] ------------------------------------------------------------------------
2020-05-15T15:31:58.1126382Z [INFO] Total time: 1.621 s
2020-05-15T15:31:58.1127089Z [INFO] Finished at: 2020-05-15T15:31:57Z
2020-05-15T15:31:58.1127980Z [INFO] ------------------------------------------------------------------------
2020-05-15T15:31:58.1129910Z [ERROR] Failed to execute goal on project Tests: Could not resolve dependencies for project com.pluralsight:Tests:jar:0.0.1-SNAPSHOT: Could not find artifact com.pluralsight:TestFramework:jar:0.0.1-SNAPSHOT -> [Help 1]
2020-05-15T15:31:58.1130901Z [ERROR]
2020-05-15T15:31:58.1131330Z [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
2020-05-15T15:31:58.1132008Z [ERROR] Re-run Maven using the -X switch to enable full debug logging.
2020-05-15T15:31:58.1132234Z [ERROR]
2020-05-15T15:31:58.1132574Z [ERROR] For more information about the errors and possible solutions, please read the following articles:
2020-05-15T15:31:58.1133037Z [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
2020-05-15T15:31:58.1149156Z No test result files matching /home/vsts/work/1/s/**/surefire-reports/TEST-*.xml were found, so publishing JUnit test results is being skipped.
2020-05-15T15:31:58.1177703Z ##[error]Build failed.
2020-05-15T15:31:58.1207997Z ##[section]Finishing: Maven
Java解决方案信息:
此屏幕截图显示了整个 Java 解决方案结构和 Azure 管道文件的位置:
此屏幕截图显示了两个 Java 项目的结构:
这是我到目前为止创建的 Azure 管道文件:
# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Maven@3
inputs:
mavenPomFile: './Tests/pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'test'
Tests 项目的 Maven pom 文件是:
<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.pluralsight</groupId>
<artifactId>Tests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.pluralsight</groupId>
<artifactId>TestFramework</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
TestFramework 项目的 Maven pom 文件是:
<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.pluralsight</groupId>
<artifactId>TestFramework</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
解决方案
我认为正如其他人提到的那样,因为构建代理没有 TestFramework 工件并且不能从任何地方拉它。
TestFramework 的代码可能已被拉入构建代理,但尚未构建到工件中。
你提到你可以从你的本地机器上运行它。这可能是因为您在那台机器上的某个时间点构建了 TestFramework。您可以查看 .m2 目录进行检查。
如另一条评论中所述,您可能希望发布依赖项或在构建代理上构建/复制工件。
推荐阅读
- python - PyAV:在重新混合流时强制新的帧速率?
- arrays - 在 Powershell 的新数组中仅存储 \\servername\share\
- c# - 使用 System.Text.Json.Serialization 解析 json 的异常
- python - Windows 似乎在 python str 中插入了额外的字节
- lua - How do you get the position of the side of a block so you can place a block perfectly next to the block
- c++ - c ++在函数中传递参数会出错
- oracle - 如何在 SuiteScript 2.0 中加密/解密字符串?
- python - 理解这段python代码到底能做什么?
- docker - Nginx 缓存 DNS 查找并忽略我的解析器设置
- python - Need help understanding classes in Python