XCode机器人API配置编辑失败
我想通过XCode机器人API更改机器人的方案名称。一个像curl -XPATCH -H'Content-Type:application/json'-H'x-xcsclientversion:8'https://localhost:20343/api/bots/botid123 -d'{“name”:“myawesomebot2”}'的请求来更改机器人名称。但是,如果我尝试更改配置对象的请求正文,如'{“配置”:{“schemeName”:“scheme2”}}'它失败。XCode机器人API配置编辑失败
如何修改方案名称?
我终于得到了这个解决方案,并且想要注意使这项工作以及我如何找到它的必要部分。
首先,因为你已经注意到了,就是需要-H "x-xcsclientversion: #"
(注意,6为我工作,通过接收补丁请求苹果的JavaScript的检查发现)
其次,看Xcode的服务器更新一后机器人通过查尔斯,可以看出的是,URL需要添加下述参数,?overwriteBlueprint=true
第三,它似乎是JSON数据,在最上面的水平name:
,还要求requiresUpgrade=false
和type=1
(I found the tool jq是无价)
第四,对sourceBlueprint
的更改需要configuration.sourceControlBlueprint.DVTSourceControlWorkspaceBlueprintIdentifierKey
才能接收新的UUID。通过uuidgen
命令在bash中轻松生成。
第五,必须发送大部分完整的机器人描述。我通过Apple的API抓取了机器人的JSON定义,然后使用jq
(参见上文)修改了它,删除了不必要的键/值对,以匹配Xcode Server自己的API调用。必要的键/值对似乎是:
- 名称
- 类型
- requiresUpgrade
- 配置(修改为必要的,但全配置必须被发送)
- 组(离开原样但是将其发回)
六,反斜杠 - 在JSON有效负载中转义所有正斜杠。我在bash中用ESCAPED_JSON=${BOT_CONFIG_JSON//\//\\\/}
完成了这个操作,并且我在curl命令中发送了-d "$ESCAPED_JSON"
。
因此,我使用的是全curl命令变为:
curl -k --request PATCH -H "Content-Type: application/json" -H "x-xcsclientversion: 6" -d "$ESCAPED_JSON" https://<username>:<password>@<your_server_address>:20343/api/bots/<your_bot_id>?overwriteBlueprint=true
而一个完整的JSON定义(请记住,它必须有正斜杠发送之前转义)看起来像这样
<!-- language: lang-json -->
"requiresUpgrade": false,
"configuration": {
"triggers": [
{
"phase": 1,
"scriptBody": "<REDACTED>",
"type": 1,
"name": "Update github Pending",
"conditions": {
"status": 2,
"onSuccess": true,
"onAnalyzerWarnings": true,
"onBuildErrors": true,
"onWarnings": true,
"onFailingTests": true
}
},
{
"phase": 2,
"scriptBody": "<REDACTED>",
"type": 1,
"name": "Upload to Beta",
"conditions": {
"status": 2,
"onSuccess": true,
"onAnalyzerWarnings": true,
"onBuildErrors": false,
"onWarnings": true,
"onFailingTests": false
}
},
{
"phase": 2,
"scriptBody": "<REDACTED>",
"type": 1,
"name": "Update github status",
"conditions": {
"status": 2,
"onSuccess": true,
"onAnalyzerWarnings": true,
"onBuildErrors": false,
"onWarnings": true,
"onFailingTests": false
}
}
],
"performsUpgradeIntegration": true,
"disableAppThinning": true,
"deviceSpecification": {
"filters": [
{
"platform": {
"_id": "3c884e2499df662057e8c64580003419",
"displayName": "iOS",
"_rev": "8-51c114fcfc83ea5f36df66f119b34ec8",
"simulatorIdentifier": "com.apple.platform.iphonesimulator",
"identifier": "com.apple.platform.iphoneos",
"buildNumber": "14C89",
"version": "10.2"
},
"filterType": 3,
"architectureType": 0
}
],
"deviceIdentifiers": [
"6d928bd891b83b4b8592aedb42001a97",
"6d928bd891b83b4b8592aedb4200776c",
"fa737f03db7b6c04d4c7f9507100700f"
]
},
"periodicScheduleInterval": 0,
"schemeName": "<REDACTED>",
"codeCoveragePreference": 2,
"performsTestAction": true,
"scheduleType": 3,
"performsArchiveAction": true,
"builtFromClean": 2,
"buildConfiguration": "Release",
"performsAnalyzeAction": true,
"sourceControlBlueprint": {
"DVTSourceControlWorkspaceBlueprintLocationsKey": {
"A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1": {
"DVTSourceControlWorkspaceBlueprintLocationTypeKey": "DVTSourceControlLockedRevisionLocation",
"DVTSourceControlLocationRevisionKey": "9d38dc7507f0f6ac17072d721893f0021c5282ed"
},
"51DBFAD1848AC646B864BBBEDC625B8BAB305A76": {
"DVTSourceControlBranchIdentifierKey": "<THE BRANCH TO WATCH>",
"DVTSourceControlBranchOptionsKey": 4,
"DVTSourceControlWorkspaceBlueprintLocationTypeKey": "DVTSourceControlBranch"
}
},
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey": "51DBFAD1848AC646B864BBBEDC625B8BAB305A76",
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey": {},
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationStrategiesKey": {
"A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1": {
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationTypeKey": "DVTSourceControlAuthenticationStrategy"
},
"51DBFAD1848AC646B864BBBEDC625B8BAB305A76": {
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationTypeKey": "DVTSourceControlAuthenticationStrategy"
}
},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey": {
"A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1": 0,
"51DBFAD1848AC646B864BBBEDC625B8BAB305A76": 0
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey": "<GENERATE A NEW UUID FOR THIS!!!>",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey": {
"A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1": "<REDACTED PATH 1>",
"51DBFAD1848AC646B864BBBEDC625B8BAB305A76": "<REDACTED PATH 2>"
},
"DVTSourceControlWorkspaceBlueprintNameKey": "Cool Blueprint",
"DVTSourceControlWorkspaceBlueprintVersion": 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey": "<REDACTED>.xcworkspace",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey": [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey": "[email protected]:<REDACTED REPO 1>",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey": "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey": "A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1"
},
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey": "[email protected]:<REDACTED REPO 2>",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey": "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey": "51DBFAD1848AC646B864BBBEDC625B8BAB305A76"
}
]
},
"exportsProductFromArchive": true,
"weeklyScheduleDay": 0,
"minutesAfterHourToIntegrate": 0,
"testingDestinationType": 0,
"hourOfIntegration": 0,
"testingDeviceIDs": []
},
"group": {
"name": "41A62776-A72E-44C0-BFF0-D91F699BBA6A"
},
"type": 1,
"name": "My Cool Integration Bot"
我希望这有助于。
xcode不会更新机器人。它发送一个大部分完整的配置json对象。只发送更新后的属性似乎不起作用。即使文件说它应该工作。 – ideveloper
准确无误。最终,我的成功来源于模仿Xcode的尽可能精确,包括发送似乎没有必要的数据(为什么重新发送每个集成脚本?!) – christopherdrum
你有没有想过这个? 到目前为止,在我的测试中,我已经能够设置一个-d JSON有效载荷 '{“name”:“cool_bot”,“configuration”:{“scheduleType”:2}}' 这就是它。修改类似sourceControlBlueprint(所以我可以将bot指向repo上的新分支)似乎被忽略或返回“Class of object((null))不是XCSBotConfiguration的子类” 您的类似问题, 我猜? 你有没有遇到过解决方案? – christopherdrum