SonarQube
2 TopicsAzure DevOps - How to modify files during a Build Pipeline execution based on PowerShell
Azure DevOps Build Pipeline can provide several option, but sometime we need to change a part of content extracted from Source code management (e.g. Git) before execute another task. In my case, this case is to comment one specific declaration (#include) placed in couple of JavaScript files. These lines are understood well by the application server using this code, but not by generic JavaScript parser used for example into SonarQube. So into the Pipeline process, it's only a PowerShell task could be used to do that like following. In Yaml mode: steps: - powershell: | Write-Host "------------------------------------------------------------" Write-Host "Get JS File content containing #include line", $(Agent.WorkFolder) Write-Host "------------------------------------------------------------" $AllJSFIleToManage = Get-ChildItem -Path $(Agent.WorkFolder)\*.js -Recurse -Force | Select-String -Pattern "#include " -AllMatches | Foreach {$_.Path} | Select-Object -Unique foreach ($MyFile in $AllJSFIleToManage) { Write-Host "JS File to change -", $MyFile (Get-Content $MyFile -Encoding UTF8) -replace '#include ', '//#include ' | Set-Content $MyFile Write-Host "JS File changed -", $MyFile Write-Host " -----------------------------------" } displayName: 'PowerShell Script remove specific #Include lines from JS files for Sonar' In Visual Editor mode: When the pipeline is running, it will get the source code from Git and change dynamically only the JS files replacing the blocks found with this "#include" by "//#include" to comment the concerned lines in JavaScript. The result of this execution in Pipeline log is like following: Into SonarQube the result is visible via the Source Code navigation option: You can adapt this code with your specific case and need, but PowerShell tasks are really powerful when you need to change something before a specific step only during the Pipeline execution. Fabrice Romelard61KViews2likes2CommentsCode Coverage 0.0% for TSQL Projects(Contains Stored Procedures, Tables, Scripts etc)
We have used MSTest as testing framework for writing all Stored Procedures unit test case for TSQL projects. Its showing now 0.0% coverage for all Stored Procedures though all are having the valid Unit Test cases. Is it possible to do code coverage for TSQL projects? The code coverage is working fine for .NET web projects. Any help will be appreciated.548Views0likes0Comments