Cannot create subsequent releases using AzureStaticWebApp@0 while building via Oryx
- Dominant language
- No language data
- Stars
- 346
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
I am using the AzureStaticWebApp@0 in my `RELEASE` pipeline, but on a subsequent releases I face an error `Failed to create Release artifact directory`
```
2024-05-09T18:50:49.5556994Z Creating artifacts directory: /home/ritesh/agent-1/_work/r37/a
2024-05-09T18:50:49.5684499Z Failed to create Release artifact directory /home/ritesh/agent-1/_work/r37/a with an exception Microsoft.VisualStudio.Services.Agent.Worker.Release.Artifacts.ArtifactDirectoryCreationFailedException: Failed to create Release artifact directory '/home/ritesh/agent-1/_work/r37/a'.
---> System.UnauthorizedAccessException: Access to the path '/home/ritesh/agent-1/_work/r37/a/_MyRepoCloned/nuxt.config.ts' is denied.
---> System.IO.IOException: Permission denied
--- End of inner exception stack trace ---
at System.IO.FileSystem.DeleteFile(String fullPath)
at System.IO.FileInfo.Delete()
at Microsoft.VisualStudio.Services.Agent.Util.IOUtil.<>c__DisplayClass11_0.b__0(FileSystemInfo item) in /home/vsts/work/1/s/src/Agent.Sdk/Util/IOUtil.cs:line 152
at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()
at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
at System.Linq.Parallel.QueryTask.RunTaskSynchronously(Object o)
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.Services.Agent.Worker.Release.ReleaseFileSystemManager.EnsureEmptyDirectory(String directoryPath, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/Agent.Worker/Release/ReleaseFileSystemManager.cs:line 66
at Microsoft.VisualStudio.Services.Agent.Worker.Release.ReleaseJobExtension.<>c__DisplayClass41_0.b__1() in /home/vsts/work/1/s/src/Agent.Worker/Release/ReleaseJobExtension.cs:line 326
at Microsoft.VisualStudio.Services.Agent.Worker.Release.RetryExecutor.Execute(Action action) in /home/vsts/work/1/s/src/Agent.Worker/Release/RetryExecutor.cs:line 41. Retrying the creation of Release artifact directory.
2024-05-09T18:50:49.5695823Z Creating artifacts directory: /home/ritesh/agent-1/_work/r37/a
2024-05-09T18:50:49.5710878Z Failed to create Release artifact directory /home/ritesh/agent-1/_work/r37/a with an exception Microsoft.VisualStudio.Services.Agent.Worker.Release.Artifacts.ArtifactDirectoryCreationFailedException: Failed to create Release artifact directory '/home/ritesh/agent-1/_work/r37/a'.
```
**To Reproduce**
Steps to reproduce the behavior:
```
#Your build pipeline references a secret variable named ‘static.Token’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972
steps:
- task: AzureStaticWebApp@0
displayName: 'Static Web App: '
inputs:
workingDirectory: '$(System.DefaultWorkingDirectory)/_MyRepoCloned'
app_build_command: 'npm i && npm run build'
output_location: dist
skip_app_build: false
skip_api_build: true
is_static_export: true
verbose: false
azure_static_web_apps_api_token: '$(static.Token)'
```
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Device info (if applicable):**
- OS: Ubuntu 22.04.4 LTS x86_64
- Agent: Self_hosted
**Additional context**
What I have debugged is that after creating the folder `_MyRepoCloned` from a user account `ritesh` when Oryx starts to build for the first time using npm this file gets owned by `root`, causing the issue in the subsequent release.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.