'The system path generated cucumber/karate html report is not accessible in Azure DevOps pipeline

We created a karate framework with API testing using Maven, and we successfully ran it locally, generating both reports: a karate html report and a cucumber html report. We have added the cucumber html report dependency to our POM.xml. Because karate-related tasks are not available in Azure, but cucumber-related tasks are supported in Azure, like html report generation (i.e., publishing a cucumber report).

I have been trying from a couple of days to resolve the following error but I am unable to resolve it:

My module's pom.xml file is:

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.test</groupId>
   <artifactId>karate</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <name>project</name>
   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <java.version>1.8</java.version>
      <maven.compiler.version>3.6.0</maven.compiler.version>
      <karate.version>1.0.1</karate.version>
   </properties>
   <dependencies>
      <dependency>
         <groupId>com.intuit.karate</groupId>
         <artifactId>karate-junit4</artifactId>
         <version>1.1.0</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>com.intuit.karate</groupId>
         <artifactId>karate-apache</artifactId>
         <version>0.9.6</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>4.13.2</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>io.cucumber</groupId>
         <artifactId>cucumber-java8</artifactId>
         <version>7.0.0</version>
      </dependency>
      <dependency>
         <groupId>io.cucumber</groupId>
         <artifactId>cucumber-junit</artifactId>
         <version>7.2.2</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>io.cucumber</groupId>
         <artifactId>cucumber-picocontainer</artifactId>
         <version>4.2.6</version>
      </dependency>
      <dependency>
         <groupId>net.masterthought</groupId>
         <artifactId>cucumber-reporting</artifactId>
         <version>3.8.0</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>log4j</groupId>
         <artifactId>log4j</artifactId>
         <version>1.2.17</version>
      </dependency>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <version>1.3.2.RELEASE</version>
         <type>pom</type>
      </dependency>
      <dependency>
         <groupId>com.oracle.database.jdbc</groupId>
         <artifactId>ojdbc8</artifactId>
         <version>19.13.0.0.1</version>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-jdbc</artifactId>
         <version>5.3.14</version>
      </dependency>
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-api</artifactId>
         <version>1.7.32</version>
      </dependency>
   </dependencies>
   <build>
      <testResources>
         <testResource>
            <directory>src/test/java</directory>
            <excludes>
               <exclude>**/*.java</exclude>
            </excludes>
         </testResource>
      </testResources>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M3</version>
            <!--<configuration>
                    <properties>
                        <property>
                            <name>usedefaultlisteners</name>
                            <value>false</value>
                        </property>
                    </properties>
                    <testSourceDirectory>src/test/java</testSourceDirectory>
                    <includes>
                        <include>KarateAPITesting/src/test/java/features/</include>
                    </includes>
                    <reportsDirectory>target/site/</reportsDirectory>
                </configuration>-->
            <configuration>
               <argLine>-Dfile.encoding=UTF-8</argLine>
            </configuration>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>3.0.0-M5</version>
            <!--    <configuration>
                    <outputDirectory>/KarateAPITesting/src/test/java/target/surefire-reports</outputDirectory>
                    <linkXRef>false</linkXRef>
                </configuration> -->
            <executions>
               <execution>
                  <phase>test</phase>
                  <goals>
                     <goal>report-only</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>2.1</version>
            <configuration>
               <outputDirectory>KarateAPITesting/src/test/java/target/surefire-reports/</outputDirectory>
            </configuration>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
               <source>1.8</source>
               <target>1.8</target>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>

We have added the below tasks to 'azure-pipelines.yml' under "build pipeline"-

# Starter pipeline

# Start with a minimal pipeline that you can customize to build and deploy your code.

# Add steps that build, run tests, deploy, and more:

# https://aka.ms/yaml

trigger:

  • master

pool: vmImage: 'windows-2019' variables:

  • group: DEV - QA Automation steps:
  • task: Maven@3 inputs: mavenPomFile: 'karate/pom.xml' goals: 'clean' mavenOptions: '-Xmx3072m' javaHomeOption: 'JDKVersion' jdkVersionOption: '1.11' jdkArchitectureOption: 'x64'
    publishJUnitResults: true testResultsFiles: '**/surefire-reports/Test.*.xml'
  • task: CopyFiles@2 inputs: SourceFolder: '' Contents: '**' TargetFolder: '$(build.artifactstagingdirectory)'
  • task: PublishBuildArtifacts@1 inputs: ArtifactName: 'drop' TargetPath: '$(Build.ArtifactStagingDirectory)'

As we have added the above tasks to the build pipeline, it has run successfully —

Once ‘create release’ using the default agent pool on the release pipeline side. Observed the following error-

  1. The system path generated cucumber/karate html report is not accessible in the default agent pool under the release pipeline.

Failed to parse result files: System.UnauthorizedAccessException: Access to the path 'C:\agent_work\r3\a_QA Automation\drop\karate\target\cucumber-html-reports' is denied.

2. The maven goal test failed. Tried multiple versions (like 2.19.1, 3.0.0-M1, 3.0.0-M3, 3.0.0-M5) POM.xml for maven-surefire-plugin. Similar error is observed.

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project karate.

Note: We tried multiple versions (like 2.19.1, 3.0.0-M1, 3.0.0-M3, 3.0.0-M5) POM.xml for maven-surefire-plugin. Similar error is observed.

Details log is as below – 2022-03-24T08:53:42.1776605Z [INFO] ------------------------------------------------------------------------ 2022-03-24T08:53:42.1777259Z [INFO] BUILD FAILURE 2022-03-24T08:53:42.1777937Z [INFO] ------------------------------------------------------------------------ 2022-03-24T08:53:42.1778614Z [INFO] Total time: 37.189 s 2022-03-24T08:53:42.1779210Z [INFO] Finished at: 2022-03-24T04:53:42-04:00 2022-03-24T08:53:42.1779985Z [INFO] ------------------------------------------------------------------------ 2022-03-24T08:53:42.1781192Z [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project karate: There are test failures. 2022-03-24T08:53:42.1782123Z [ERROR] 2022-03-24T08:53:42.1784097Z [ERROR] Please refer to C:\agent_work\r3\a_QA Automation\drop\karate\target\surefire-reports for the individual test results. 2022-03-24T08:53:42.1785210Z [ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream. 2022-03-24T08:53:42.1785933Z [ERROR] -> [Help 1] 2022-03-24T08:53:42.1786311Z [ERROR] 2022-03-24T08:53:42.1786933Z [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 2022-03-24T08:53:42.1787747Z [ERROR] Re-run Maven using the -X switch to enable full debug logging. 2022-03-24T08:53:42.1788323Z [ERROR] 2022-03-24T08:53:42.1789020Z [ERROR] For more information about the errors and possible solutions, please read the following articles: 2022-03-24T08:53:42.1790006Z [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 2022-03-24T08:53:42.2978255Z The process 'C:\apache-maven-3.8.5\bin\mvn.cmd' failed with exit code 1 2022-03-24T08:53:42.2979841Z Could not retrieve code analysis results - Maven run failed. 2022-03-24T08:53:44.1664964Z Result Attachments will be stored in LogStore 2022-03-24T08:53:44.2086684Z Run Attachments will be stored in LogStore 2022-03-24T08:53:44.3650165Z Failed to parse result files: System.UnauthorizedAccessException: Access to the path 'C:\agent_work\r3\a_QA Automation\drop\karate\target\cucumber-html-reports' is denied. at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle) at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy) at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) at System.Xml.XmlTextReaderImpl.FinishInitUriString() at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver) at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext) at System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings) at Microsoft.TeamFoundation.TestClient.PublishTestResults.JUnitResultParser.ReadFile(String filePath, XmlDocument doc) at Microsoft.TeamFoundation.TestClient.PublishTestResults.JUnitResultParser.ParseTestResultFile(TestRunContext runContext, String filePath) at Microsoft.TeamFoundation.TestClient.PublishTestResults.JUnitResultParser.<>c__DisplayClass1_0.<ParseTestResultFiles>b__0(String file) at System.Linq.Enumerable.SelectListIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.ToList() at Microsoft.TeamFoundation.TestClient.PublishTestResults.JUnitResultParser.ParseTestResultFiles(TestRunContext runContext, IList1 resultFilePaths) at Microsoft.VisualStudio.Services.Agent.Worker.TestResults.Parser.ParseFiles(IExecutionContext executionContext, TestRunContext testRunContext, List1 testResultsFiles, ITestResultParser testResultParser) 2022-03-24T08:53:44.3778029Z ##[error]Build failed. 2022-03-24T08:53:44.3847904Z ##[section]Async Command Start: Publish test results 2022-03-24T08:53:44.4590591Z ##[section]Async Command End: Publish test results 2022-03-24T08:53:44.4593989Z ##[section]Finishing: maven



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source