selenium-webdriveryamlazure-pipelinescucumber-java

Can you let me know what all needs to be updated in azuree-pipeline.yml file for selenium cucumber framework by using java


below is the snap of the yml file: please correct me if I am doing something wrong. I am facing exception while triggering the build using pipeline. Added our project structure below enter image description here

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'

Solution

  • In Azure DevOps Microsoft-hosted agent, the pre-install Java 11 version is 11.0.21.

    But your project requests Java version 11.0.19_7. So you need to add steps to install the Java version 11.0.19_7.

    Refer to the 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'
    

    In this case, you can keep the Java version: 11.0.19_7 in your Pom.xml file. <java.version>11.0.19_7</java.version>