microsoft/azure-pipelines-task-lib

TestPublisher.publish System.IO.IOException: Permission denied

epszaw opened this issue · 9 comments

Please check our current Issues to see if someone already reported this https://github.com/Microsoft/azure-pipelines-task-lib/issues

Environment

azure-pipelines-task-lib version: 2.9.3

Issue Description

When I try to publish files generated by previously installed program, I got an error: System.IO.IOException: Permission denied.

I found information, that it can happen when another process works with the files, but in my case, I can't figure out, what's wrong because "generator" process does nothing with the files.

There is a code I use inside the task:

import * as taskLib from "azure-pipelines-task-lib/task"

// ...

const allureTool = taskLib.tool(taskLib.which('allure', true))

allureTool.arg(['generate', '-o', outputReportPath, testResultsPath])

const allureRes = allureTool.execSync()

if (allureRes.code !== 0) {
   throw new Error("Failed to generate allure report!")
}

const testPublisher = new taskLib.TestPublisher("JUnit")

testPublisher.publish(outputReportPath, "true", "", "", "", "true")

Task logs

2022-12-15T14:19:38.8826730Z ##[section]Starting: publish allure report
2022-12-15T14:19:38.8832927Z ==============================================================================
2022-12-15T14:19:38.8833187Z Task         : Publish Allure Report
2022-12-15T14:19:38.8833363Z Description  : Publish Allure Report
2022-12-15T14:19:38.8833530Z Version      : 1.0.24
2022-12-15T14:19:38.8833675Z Author       : qameta software
2022-12-15T14:19:38.8833815Z Help         : 
2022-12-15T14:19:38.8834025Z ==============================================================================
2022-12-15T14:19:39.0971469Z Downloading: https://github.com/allure-framework/allure2/releases/download/2.20.1/allure-2.20.1.tgz
2022-12-15T14:19:40.1518748Z Extracting archive
2022-12-15T14:19:40.1563867Z [command]/usr/bin/tar xC /home/vsts/work/_temp/7403c5da-7b93-4366-bc5d-9ba7ed36b4b7 -f /home/vsts/work/_temp/b07ed998-c36d-472e-8bdd-31b3a053a075
2022-12-15T14:19:40.3614343Z Caching tool: allure 2.20.1 x64
2022-12-15T14:19:40.4219444Z Prepending PATH environment variable with directory: /home/vsts/work/_temp/7403c5da-7b93-4366-bc5d-9ba7ed36b4b7/allure-2.20.1/bin
2022-12-15T14:19:40.4239107Z [command]/home/vsts/work/_temp/7403c5da-7b93-4366-bc5d-9ba7ed36b4b7/allure-2.20.1/bin/allure generate -o /home/vsts/work/1/s/example-report-1 /home/vsts/work/1/s/allure-results
2022-12-15T14:19:43.4351458Z Report successfully generated to /home/vsts/work/1/s/example-report-1
2022-12-15T14:19:45.2566950Z Result Attachments will be stored in LogStore
2022-12-15T14:19:45.3333126Z Run Attachments will be stored in LogStore
2022-12-15T14:19:45.4042872Z Failed to parse result files: System.UnauthorizedAccessException: Access to the path '/home/vsts/work/1/s/example-report-1' is denied.
 ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   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.SelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.ToList()
   at Microsoft.TeamFoundation.TestClient.PublishTestResults.JUnitResultParser.ParseTestResultFiles(TestRunContext runContext, IList`1 resultFilePaths)
   at Microsoft.VisualStudio.Services.Agent.Worker.TestResults.Parser.ParseFiles(IExecutionContext executionContext, TestRunContext testRunContext, List`1 testResultsFiles, ITestResultParser testResultParser)
2022-12-15T14:19:45.4101298Z ##[section]Async Command Start: Publish test results
2022-12-15T14:19:45.5139546Z ##[section]Async Command End: Publish test results
2022-12-15T14:19:45.5141816Z ##[section]Finishing: publish allure report

Expected behaviour

Files should be published without access issue

Actual behaviour

I get Failed to parse result files: System.UnauthorizedAccessException: Access to the path '...' error all the time I try to publish any file generated inside the task.

Steps to reproduce

  1. Create a new task
  2. Add allure-commandline node dependency
  3. Use the dependency via node tool and generate a report (can be generated with any folder as input)
  4. Try to publish the report

Hi @epszaw, thanks for reporting! We are working on more prioritized issues at the moment but will get back to this one soon.

@kirill-ivlev Are you going to take this ticket in work anytime soon?

This issue has had no activity in 90 days. Please comment if it is not actually stale

baev commented

Up

This issue has had no activity in 90 days. Please comment if it is not actually stale

baev commented

ping

This issue has had no activity in 90 days. Please comment if it is not actually stale

baev commented

ping

This issue has had no activity in 90 days. Please comment if it is not actually stale