一段时间以来,我在 TFS CI 构建过程中对 IBM uDeploy 命令行客户端 (udclient) 进行了 PowerShell 脚本调用。
我的 udclient 调用的脚本如下:
udclient.cmd -weburl $uDeployServer -authtoken $authToken "importVersions" $requestJson
...我的 JSON 文件 ($requestJson) 内容如下所示:
{
"component": "[uDeploy component name]",
"properties": {
"version": "[component version]"
}
}
直到最近,这些请求以及后续的 udclient 版本部署请求一直在按预期工作。然而,几周前,版本导入请求开始神秘地失败。
在 uDeploy UI 中,在 Component Configuration 的 Version Import History 选项卡中,我可以看到失败的 Import Requests。
但是,当我打开输出日志进行检查时,它是空的。错误日志仅包含以下内容:
"版本导入失败,原因如下:找不到 JSONObject["value"]。"
从 uDeploy UI 手动导入版本仍按预期工作。
此外,一旦应用人工干预完成 CI 构建中的版本导入,后续版本部署请求将毫无问题地执行。
我不是 Java 专家,但在我看来,该错误表明 JSON 文件有问题。但是,要测试我的 JSON(我使用的是 PS 5,直到 PS 6 才使用 Test-Json),请执行以下 PowerShell 脚本:
try {
$json = Get-Content -Path [component version import].json | ConvertFrom-Json
Write-Host "JSON is valid."
} catch {
Write-Host "JSON is dodgy."
}
...返回:
JSON 是有效的。
发生什么了?这可能与 JSON 文件中的编码有关吗?想法和见解受到赞赏;感谢您的关注。