首页 > 解决方案 > 带有 powershell 的 Jenkinsfile。需要帮助处理引号、三双引号和转义字符

问题描述

再会,

我一直在努力处理三双引号,三单引号,转义引号......

我需要执行一个带有引号的 Powershell 命令。

我有什么:

testsDll = powershell(returnStdout: true, script: '((Get-ChildItem -Path $env:WORKSPACE\\src\\Web\\*Unit.Tests.dll -Recurse) -join " ")').trim()

TestDllWithParameters = "$testsDll" + " /TestAdapterPath:" + "${env.WORKSPACE}" + "\\src\\Web\\packages\\NUnit3TestAdapter.3.16.1 /Logger:trx;LogFileName=Web123456.trx /TestCaseFilter:TestCategory!=DEADLOCK^&TestCategory!=QUARANTINE^&TestCategory!=Quarantine^&TestCategory!=NotImplemented^&TestCategory!=InProgress^&TestCategory!=INTEGRATION^&TestCategory!=Integration"
VSCodeExeFullPath =  "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" 

env.VSTESTEXITCODE_WEB = powershell(returnStatus: true, script: """
   Start-Process "$VSCodeExeFullPath" -ArgumentList "$TestDllWithParameters" -NoNewWindow
""")'

变量插值有效。我遇到的问题是我想保留两个引号$VSCodeExeFullPath$TestDllWithParameters因为两者都包含空格。

谢谢!

标签: powershelljenkinsjenkins-pipelinejenkins-groovy

解决方案


推荐阅读