下面是 yml 文件的快照:如果我做错了什么,请纠正我。我在使用管道触发构建时遇到异常。 在下面添加了我们的项目结构
trigger:
- local
pool:
vmImage: windows-latest
steps:
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '11'
jdkArchitectureOption: 'x64'
publishJUnitResults: false
testResultsFiles: '**/cucumber.json'
testRunTitle: 'Cucumber Tests'
searchFolder: '$(System.DefaultWorkingDirectory)'
pathToPublish: 'test-output' # Update this with the path to your Extent Reports
artifactName: 'extentreports'
goals: 'verify'
在 Azure DevOps Microsoft 托管代理中,预安装 Java 11 版本为 11.0.21。
但是您的项目需要 Java 版本 11.0.19_7。所以需要添加安装Java版本11.0.19_7的步骤。
参考Yaml:
pool:
vmImage: windows-latest
steps:
- powershell: |
$source = "https://builds.openlogic.com/downloadJDK/openlogic-openjdk-jre/11.0.19+7/openlogic-openjdk-jre-11.0.19+7-windows-x64.zip"
$destination = "$(build.sourcesdirectory)\openlogic-openjdk-jre-11.0.19+7-windows-x64.zip"
$client = new-object System.Net.WebClient
$cookie = "oraclelicense=accept-securebackup-cookie"
$client.Headers.Add([System.Net.HttpRequestHeader]::Cookie, $cookie)
$client.downloadFile($source, $destination)
displayName: 'PowerShell Script'
- task: JavaToolInstaller@0
displayName: 'Use Java 11'
inputs:
versionSpec: 11
jdkArchitectureOption: x64
jdkSourceOption: LocalDirectory
jdkFile: '$(build.sourcesdirectory)\openlogic-openjdk-jre-11.0.19+7-windows-x64.zip'
jdkDestinationDirectory: '$(agent.toolsDirectory)/jdk11'
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '11'
jdkArchitectureOption: 'x64'
publishJUnitResults: false
testResultsFiles: '**/cucumber.json'
testRunTitle: 'Cucumber Tests'
searchFolder: '$(System.DefaultWorkingDirectory)'
pathToPublish: 'test-output' # Update this with the path to your Extent Reports
artifactName: 'extentreports'
goals: 'verify'
在这种情况下,您可以在 Pom.xml 文件中保留 Java 版本:11.0.19_7。
<java.version>11.0.19_7</java.version>