我的脚本中的这种情况总是被评估为true并显示“是的,等于是在运行阶段”
stage('test cond'){
if(env.BUILD_TESTING2 == true){
echo "Yes equal - running the stage"
} else {
echo "Not equal - skipping the stage"
}
}
Run Code Online (Sandbox Code Playgroud)
即使我通过设置env.BUILD_TESTING2 = false开始构建,它仍然会输入条件并显示“是的-运行阶段”。
我也尝试过这种语法:
stage('test cond'){
if(env.BUILD_TESTING2){
echo "Yes equal - running the stage"
} else {
echo "Not equal - skipping the stage"
}
}
Run Code Online (Sandbox Code Playgroud)
但是它仍然总是被评估为true。
如何在Jenkins脚本化管道中编写带有布尔参数的条件步骤?
我正在尝试获取 Google Chrome 的版本号,但找不到。
我可以看到 chrome 已安装:

我尝试使用PowerShell:
get-wmiobject Win32_Product | Format-Table IdentifyingNumber, Name, LocalPackage -AutoSize
Run Code Online (Sandbox Code Playgroud)
但我得到的是一个不包含“Google Chrome”的列表。
如何获取 Chrome 浏览器的版本号?
我正在尝试使用 PowerShell 读取此 XML 文件:
<?xml version='1.1' encoding='UTF-8'?>
<Root>
<element1>
<string>name</string>
</element1>
<version>3.2.1</version>
</Root>
Run Code Online (Sandbox Code Playgroud)
我使用的 PowerShell 命令:
$fileContent = New-Object XML
$fileContent.Load($filePath) # $filePath contains the path to the XML file above
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
使用“1”个参数调用“Load”时出现异常:“版本号‘1.1’无效。
如果我删除标题<?xml version='1.1' encoding='UTF-8'?>或对其进行注释 ( <!-- <?xml version='1.1' encoding='UTF-8'?> -->),我就不会再收到错误。问题是我需要那个标题。
如何使用 PowerShell 读取带有标头的 XML 文件?