【问题标题】:App Store Connect API last uploaded build version and numberApp Store Connect API 上次上传的构建版本和编号
【发布时间】:2019-05-29 14:24:25
【问题描述】:

我正在设置 CI/CD 应用部署以将构建上传到 TestFlight/AppStore,因此需要在构建之前检查之前从 App Store Connect 上传的构建版本

我已生成使用 App Store Connect API 进行身份验证所需的 JWT 令牌,并从以下位置获取应用 ID:https://api.appstoreconnect.apple.com/v1/apps

现在我正在请求与该应用 ID 相关的构建,使用:https://api.appstoreconnect.apple.com/v1/apps/{id}/builds

这给了我这个响应(响应数据是分页的(偏移量/限制)并且不按上传的构建版本排序):-

{
    "data": [
        {
            "type": "preReleaseVersions",
            "id": "<resource id>",
            "attributes": {
                "version": "1.3",
                "platform": "IOS"
            },
            <some additional trees>
        },
        {
            "type": "preReleaseVersions",
            "id": "<resource id>",
            "attributes": {
                "version": "1.4",
                "platform": "IOS"
            },
            <some additional trees>
        },
        {
            "type": "preReleaseVersions",
            "id": "<resource id>",
            "attributes": {
                "version": "1.2",
                "platform": "IOS"
            },
            <some additional trees>
        },
        <some more data...>
    ],
    "meta": {
        "paging": {
            "total": 55,
            "limit": 50
        }
    }
}

我正在寻找的是一些查询字符串参数或不同的 API 或方法,我可以从中获取最新的构建版本,而无需递归调用 API 来获取所有上传的版本,然后从数组中找到最大的版本

【问题讨论】:

标签: ios continuous-integration app-store-connect continuous-deployment


【解决方案1】:

我还没有找到一个简单的方法,但这是我想出的最好的方法。

https://api.appstoreconnect.apple.com/v1/builds?filter[app]={app_id}&sort=-version&fields[builds]=version&filter[preReleaseVersion.version]={version_num}&limit=1

这将返回如下内容:

{
   "data": [
    {
      "type": "builds",
      "id": "ef87f7e1-20e0-4128-9c4d-7aadb23b23ed",
      "attributes": {
        "version": "30"
      },
      "links": {
        "self": "https://api.appstoreconnect.apple.com/v1/builds/ef87f7e1-20e0-4128-9c4d-7aadb23b23ed"
      }
    }
  ],
  "links": {
    "self": "https://api.appstoreconnect.apple.com/v1/builds?filter%5BpreReleaseVersion.version%5D=1.2.11&limit=1&sort=-version&filter%5Bapp%5D=&fields%5Bbuilds%5D=version",
    "next": "https://api.appstoreconnect.apple.com/v1/builds?cursor=AQ.GXQEGw&filter%5BpreReleaseVersion.version%5D=1.2.11&limit=1&sort=-version&filter%5Bapp%5D=&fields%5Bbuilds%5D=version"
  },
  "meta": {
    "paging": {
      "total": 29,
      "limit": 1
    }
  }
}

从这里您只需获取“版本”。这很令人困惑,但在这种情况下,版本是内部版本号。

这种方法存在一个问题。有时苹果即使上传也不会处理构建。出于某种原因,这些构建不会显示在此请求中。我不明白为什么Apple对此如此固执。尽管如此,我注意到 FastLane 能够获得最新版本,但我还没有对他们的流程进行逆向工程。

【讨论】:

    【解决方案2】:

    您可以通过检查为特定 preleaseVersion 上传的构建来限制搜索:

    params = { 'filter[version]' =&gt; short_bundle_version }

    GET https://api.appstoreconnect.apple.com/v1/preReleaseVersions

    这将返回包含与该版本关联的构建 URL 的元数据。然后,您可以提取相关的构建 url:

    json['relationships']['builds']['links']['related']['data'],

    然后为 url 请求关联的 JSON,其中将包含构建 ID 及其uploadDate

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-25
      • 2020-02-10
      • 2021-06-30
      • 2021-12-16
      • 2017-03-05
      • 2021-11-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多