Sonar seams not to handle the custom escape character set in Dockerfile.
I’m am using:
- Azure DevOps (ALM and CI)
- Scanner Azure Task 1.35.0
- SonarScanner for MSBuild 5.10
- C# .Net Framework 4.8
- Docker for Windows
The first line of the Docker file is:
# escape=`
According to Docker documentation and and best practice for Docker on Windows the escape character is change to [`] because the default [\] doesn’t work well on Windows.
The Docker file
# escape=`
FROM codeless.azurecr.io/infra/iis:1809
# Add virtual directory
RUN Import-Module WebAdministration; `
New-WebApplication -Name Server -Site WebSite -PhysicalPath c:\www\WebApp;
<etc>
The Sonar scanner gives these error message:
##[error]ERROR: Unable to parse file:
file:///C:/azp_c/work/3/s/Web/Dockerfile. Parse error at position 6:0
And
##[error]1: # escape=`
A work around could be to write all the RUN command on separate lines, but that would add more layers in Docker and is not desired.