In my first question, the goal was to intentionally make the CI/CD pipeline fail if a transformation is not possible in the Web.Live.Config. I had to save the build in a variable. If a transformation is not possible,
the string "No element in the source document matches"
appears in the log. But: Although there is no key with “connectionString” in the config files, strangely the string "No element in the source document matches '/configuration/connectionStrings'"
appears. I wanted to ignore this.
Can someone help me search the log for a string but ignore the "No element in the source document matches '/configuration/connectionStrings'"
? I tried -ne
, -notmatch
and -notlike
, but it didn’t help.
Even though the string " ... warning : No element in the source document matches '/configuration/appSettings/add[@key='anotherKEY']'"
appears, the pipeline does not fail.
I’m new to PowerShell, and I would appreciate your assistance.
- echo "Verifying build…"
- |
$msbuildOutput = & $MSBUILD_PATH "$Our_ASMX_PROJECT_PATH" /Target:Rebuild /property:Configuration=Live /T:Package
$pattern = "No element in the source document matches"
$ignorePattern = "No element in the source document matches '/configuration/connectionStrings'" # ignore the specific message
$relevantMatches = $matches | Where-Object { $_ -notmatch $ignorePattern }
if ($relevantMatches)
{
Write-Host "Build failed due to missing configuration key or transformation."
exit 1
}