你能让我知道使用java在selenium cucumber框架的azuree-pipeline.yml文件中需要更新什么吗

问题描述 投票:0回答:1

下面是 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'
selenium-webdriver yaml azure-pipelines cucumber-java
1个回答
0
投票

在 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>

© www.soinside.com 2019 - 2024. All rights reserved.