I have the following azure pipeline task snippet below, running on Linux self hosted agents.
- task: DotNetCoreCLI@2
displayName: Run Dotnet Test
inputs:
command: test
#arguments: --blame-hang-timeout 2min (supported only in .net 5 and above)
projects: 'Test/UnitTests/UnitTests.csproj'
verbosityPack: detailed
What is the way to run this with sudo permissions ? Part of my tests require the execution of some external processes with sudo permissions (like dmidecode, etc).
The only way I can think of is giving up using the DotNetCoreCLI task and using a regular CmdLine or other bash script task instead (actually this is the approach I was using before, I just happened to solve an issue of not having log output being printed to the console output in a Windows host - by switching from running a dotnet test
within a script block to a DotNetCoreCLI task - and thought this would be preferable as well in my linux self hosted agents).
The user that runs the pipeline job is already configured under /etc/sudoers (this was required in order to succeed running sudo dotnet test
as I originally did, as mentioned above).