XCode Bots API配置编辑失败 [英] XCode Bots API configuration edit fails

查看:119
本文介绍了XCode Bots API配置编辑失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过XCode Bots API更改机器人的方案名称.像curl -XPATCH -H'Content-Type:application/json'-H'x-xcsclientversion:8'这样的请求

I want to change via the XCode Bots API the scheme name of a bot. A request like curl -XPATCH -H 'Content-Type: application/json' -H 'x-xcsclientversion: 8' https://localhost:20343/api/bots/botid123 -d '{"name": "myawesomebot2"}' to change the bot name works. But if I try to change the configuration object with a request body like '{"configuration": {"schemeName": "scheme2"}}' it fails.

如何修改方案名称?

推荐答案

我终于解决了这个问题,并想指出进行这项工作所需的部分以及如何找到它.

I finally got this solved and want to note the pieces necessary to make this work and how I found it.

首先,正如您已经注意到的,需要-H "x-xcsclientversion: #"(注意,对我来说有6个有效,这是通过检查接收PATCH请求的Apple Javascript发现的)

First, as you already noticed, is the need for -H "x-xcsclientversion: #" (note, 6 worked for me, as discovered through a check of Apple's Javascript that receives the PATCH request)

其次,观看Xcode Server通过Charles更新了一个漫游器之后,发现URL需要添加以下参数,?overwriteBlueprint=true

Second, after watching Xcode Server update a bot through Charles, it was seen that the URL needs the following parameter added, ?overwriteBlueprint=true

第三,似乎在JSON数据中,最高层为name:,也需要requiresUpgrade=falsetype=1(我发现工具jq 具有无价之宝)

Third, it seems that the JSON data, at the topmost level as name:, also requires requiresUpgrade=false and type=1 (I found the tool jq to be invaluable)

第四,对sourceBlueprint的更改要求configuration.sourceControlBlueprint.DVTSourceControlWorkspaceBlueprintIdentifierKey接收新的UUID.通过uuidgen命令在bash中轻松生成.

Fourth, changes to the sourceBlueprint requires configuration.sourceControlBlueprint.DVTSourceControlWorkspaceBlueprintIdentifierKey to receive a new UUID. Easily generated in bash by uuidgen command.

第五,必须发送一个几乎完整的机器人描述.我通过Apple的API抓取了该机器人的JSON定义,然后使用jq对其进行了修改(请参见上文),删除了不必要的键/值对,以匹配Xcode Server自己的API调用.必要的键/值对似乎是:

Fifth, a mostly-full bot description must be sent. I grabbed the bot's JSON definition through Apple's API, then modified it using jq (see above), deleting out unnecessary key/value pairs so as to match Xcode Server's own API calls. The necessary key/value pairs appear to be:

  • 名称
  • 类型
  • 需要升级
  • 配置(根据需要进行修改,但必须发送完整的配置)
  • 组(保持原样,但通过发送回去)

第六,反斜杠转义JSON有效负载中的所有正斜杠.我已经用ESCAPED_JSON=${BOT_CONFIG_JSON//\//\\\/}在bash中完成了此操作,并在curl命令中发送了-d "$ESCAPED_JSON".

Sixth, backslash-escape all forward-slashes in the JSON payload. I've done this in bash with ESCAPED_JSON=${BOT_CONFIG_JSON//\//\\\/} and I send -d "$ESCAPED_JSON" in the curl command.

这样,我正在使用的完全卷曲命令变为:

As such, the full curl command I'm using becomes:

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定义(请记住,发送前必须转义正斜杠)

And a full JSON definition (remember, it must have forward slashes escaped before sending) looks like this

<!-- 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": "git@github.com:<REDACTED REPO 1>",
          "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey": "com.apple.dt.Xcode.sourcecontrol.Git",
          "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey": "A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1"
        },
        {
          "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey": "git@github.com:<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 Bots API配置编辑失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆