tryzealot / fastlane-plugin-zealot

上传移动应用(iPhone、Android)到 Zealot 自建 App 分发系统 | fastlane-plugin-zealot provides upload app, debug_file and version check actions to zealot
https://zealot.ews.im/docs/developer-guide/fastlane
MIT License
9 stars 1 forks source link

设置 channel_key 或者 slug 无效 #2

Closed ziiip closed 4 years ago

ziiip commented 4 years ago

前提声明: 由于 add plugin 失败,我将 plugin 抽出来,放到 action 里面了。并关闭了 Faraday ssl 验证。

使用 plugin 时的错误信息

[15:09:29]: fastlane detected a Gemfile in the current directory
[15:09:29]: However, it seems like you didn't use `bundle exec`
[15:09:29]: To launch fastlane faster, please use
[15:09:29]: 
[15:09:29]: $ bundle exec fastlane search_plugins
[15:09:29]: 
[15:09:29]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
[15:09:30]: Installing Ruby gem 'fastlane-plugin-zealot'...
[15:09:43]: Found gem "fastlane-plugin-trello" instead of the required name "fastlane-plugin-zealot"
[15:09:45]: Successfully installed 'fastlane-plugin-zealot'
[15:09:45]: Error loading plugin 'fastlane-plugin-zealot': cannot load such file -- fastlane/plugin/zealot
[15:09:45]: It seems like you wanted to load some plugins, however they couldn't be loaded
[15:09:45]: Please follow the troubleshooting guide: https://docs.fastlane.tools/plugins/plugins-troubleshooting/
+------------------------+-----------+------------------+
|                     Used plugins                      |
+------------------------+-----------+------------------+
| Plugin                 | Version   | Action           |
+------------------------+-----------+------------------+
| fastlane-plugin-zealot | undefined | No actions found |
+------------------------+-----------+------------------+

[!] No actions were found while loading one or more plugins
    Please use `bundle exec fastlane` with plugins
    More info - https://docs.fastlane.tools/plugins/using-plugins/#run-with-plugins

主要问题描述

设置某个渠道 channel_key 的时候,上传的位置会变成 “测试版” 渠道,非原渠道。

具体 Lane

 lane :upload_app_to_zealot do
    scheme_name = "myApp"
    zealot(
      endpoint: Zealot_endpoint,
      token: Zealot_token,
      channel_key: Zealot_myApp_ios_channel_key,
      file: "./fastlane/build/"+scheme_name+".ipa"
    )
  end
DEBUG [2020-01-11 15:35:09.99]: Zealot: #<FastlaneCore::Configuration:0x00007fdafa70fd00>
DEBUG [2020-01-11 15:35:09.99]: Zealot form: {:token=>"320aaaf980e20e7b058be2d77154daaa", :channel_key=>"6795aac6577a0cbe2c29fe1223848f6d", :file=>#<UploadIO:0x00007fdafa7163f8 @content_type="application/octet-stream", @original_filename="myApp.ipa", @local_path="./fastlane/build/myApp.ipa", @io=#<File:./fastlane/build/myApp.ipa>, @opts={}>, :source=>"fastlane"}
INFO [2020-01-11 15:35:09.99]: Uploading to https://beta.myApp.me ...
DEBUG [2020-01-11 15:35:22.00]: {"version"=>1, "app_name"=>"myApp iOS 测试版", "bundle_id"=>"com.myApp.myApp", "release_version"=>"2.8.1", "build_version"=>"2", "source"=>"Web", "branch"=>nil, "git_commit"=>nil, "ci_url"=>nil, "size"=>74186451, "icon_url"=>"https://beta.myApp.me/uploads/apps/a3/r49/icons/caa9f61575cc76aec144f10f8c28905a.png", "release_url"=>"https://beta.myApp.me/channels/pBJWh/releases/49", "install_url"=>"itms-services://?action=download-manifest&url=https://beta.myApp.me/api/apps/pBJWh/1/install", "qrcode_url"=>"https://beta.myApp.me/channels/pBJWh/releases/49/qrcode?size=thumb", "changelog_list"=>[{"message"=>"没有找到更新日志,可能的原因:\n\n- 开发者很懒没有留下更新日志😂\n- 有不可抗拒的因素造成日志丢失👽"}], "created_at"=>"2020-01-11T15:35:21.757+08:00", "app"=>{"id"=>3, "name"=>"myApp"}, "scheme"=>{"id"=>8, "name"=>"测试版"}, "channel"=>{"slug"=>"pBJWh", "name"=>"iOS", "device_type"=>"ios", "bundle_id"=>"*", "git_url"=>nil, "has_password"=>false}}
INFO [2020-01-11 15:35:22.00]: Release URL: https://beta.myApp.me/channels/pBJWh/releases/49
INFO [2020-01-11 15:35:22.00]: QRCode URL: https://beta.myApp.me/channels/pBJWh/releases/49/qrcode?size=thumb
INFO [2020-01-11 15:35:22.00]: Download URL: itms-services://?action=download-manifest&url=https://beta.myApp.me/api/apps/pBJWh/1/install
INFO [2020-01-11 15:35:22.00]: Build successfully uploaded to Zealot.

+------+------------------+-------------+
|           fastlane summary            |
+------+------------------+-------------+
| Step | Action           | Time (in s) |
+------+------------------+-------------+
| 1    | default_platform | 0           |
| 2    | zealot           | 12          |
+------+------------------+-------------+

INFO [2020-01-11 15:35:22.01]: fastlane.tools finished successfully 🎉

但如果设置了 slug,就会报错:

  lane :upload_app_to_zealot do
    scheme_name = "myApp"
    zealot(
      endpoint: Zealot_endpoint,
      token: Zealot_token,
      channel_key: Zealot_myApp_ios_channel_key,
      slug: Zealot_beta_slug,
      file: "./fastlane/build/"+scheme_name+".ipa"
    )
  end
DEBUG [2020-01-11 15:39:54.04]: Zealot: #<FastlaneCore::Configuration:0x00007fd7cc4eda30>
DEBUG [2020-01-11 15:39:54.04]: Zealot form: {:token=>"320aaaf980e20e7b058be2d77154daaa", :channel_key=>"6795aac6577a0cbe2c29fe1223848f6d", :file=>#<UploadIO:0x00007fd7cc4f60b8 @content_type="application/octet-stream", @original_filename="myApp.ipa", @local_path="./fastlane/build/myApp.ipa", @io=#<File:./fastlane/build/myApp.ipa>, @opts={}>, :slug=>"bUcdE", :source=>"fastlane"}
INFO [2020-01-11 15:39:54.04]: Uploading to https://beta.myApp.me ...
DEBUG [2020-01-11 15:40:04.89]: {"error"=>"resource could not be processed with errors", "entry"=>nil}
ERROR [2020-01-11 15:40:04.89]: Error uploading to Apphost: {"error"=>"resource could not be processed with errors", "entry"=>nil}
INFO [2020-01-11 15:40:04.90]: Successfully generated documentation at path '/Volumes/Storage/Work/Carbon_WorkSpace/Repos/FastlaneSource/fastlane/README.md'

+------+------------------+-------------+
|           fastlane summary            |
+------+------------------+-------------+
| Step | Action           | Time (in s) |
+------+------------------+-------------+
| 1    | default_platform | 0           |
| 2    | zealot           | 10          |
+------+------------------+-------------+

INFO [2020-01-11 15:40:04.90]: fastlane.tools finished successfully 🎉
icyleaf commented 4 years ago

本地测试了下是没问题的,你执行的时候加下 --verbose,比如:

bundle exec fastlane upload --verbose

这个会把 response 的 body 输出出来,另外

看到你已经是加了 --verbose 标识了。

你是如何关闭 ssl 证书校验的?

icyleaf commented 4 years ago

如果是这样那只能让你看下 zealot 的日志了,找下 Started POST "/api/apps/upload" 关键词有没有抱错的地方

ziiip commented 4 years ago

我的意思是关闭了证书校验,因为我用了自签名证书,参考了这里

上传过程中就看到这些日志

zealot_1    | [9134d222-93fd-4ab2-ae26-aa9dc1ddec19] Started GET "/apps" for 172.20.0.4 at 2020-01-11 17:30:06 +0800
zealot_1    | [9134d222-93fd-4ab2-ae26-aa9dc1ddec19] Processing by AppsController#index as HTML
zealot_1    | [9134d222-93fd-4ab2-ae26-aa9dc1ddec19]   Rendering apps/index.html.slim within layouts/application
zealot_1    | [9134d222-93fd-4ab2-ae26-aa9dc1ddec19]   Rendered apps/_list.html.slim (Duration: 47.3ms | Allocations: 16673)
zealot_1    | [9134d222-93fd-4ab2-ae26-aa9dc1ddec19]   Rendered apps/_help.html.slim (Duration: 7.3ms | Allocations: 5904)
zealot_1    | [9134d222-93fd-4ab2-ae26-aa9dc1ddec19]   Rendered apps/index.html.slim within layouts/application (Duration: 69.6ms | Allocations: 26583)
zealot_1    | [9134d222-93fd-4ab2-ae26-aa9dc1ddec19]   Rendered layouts/_tips.html.slim (Duration: 0.2ms | Allocations: 8)
zealot_1    | [9134d222-93fd-4ab2-ae26-aa9dc1ddec19]   Rendered layouts/_main_sidebar.html.slim (Duration: 2.0ms | Allocations: 634)
zealot_1    | [9134d222-93fd-4ab2-ae26-aa9dc1ddec19]   Rendered layouts/_navigation.html.slim (Duration: 3.2ms | Allocations: 859)
zealot_1    | [9134d222-93fd-4ab2-ae26-aa9dc1ddec19]   Rendered layouts/_content_header.html.slim (Duration: 0.2ms | Allocations: 20)
zealot_1    | [9134d222-93fd-4ab2-ae26-aa9dc1ddec19]   Rendered layouts/_messages.html.slim (Duration: 0.9ms | Allocations: 17)
zealot_1    | [9134d222-93fd-4ab2-ae26-aa9dc1ddec19]   Rendered layouts/_content.html.slim (Duration: 2.3ms | Allocations: 151)
zealot_1    | [9134d222-93fd-4ab2-ae26-aa9dc1ddec19]   Rendered layouts/_footer.html.slim (Duration: 0.2ms | Allocations: 7)
zealot_1    | [9134d222-93fd-4ab2-ae26-aa9dc1ddec19] Completed 200 OK in 103ms (Views: 83.6ms | ActiveRecord: 13.2ms | Allocations: 29785)
web_1       | 172.20.0.1 - - [11/Jan/2020:09:30:06 +0000] "GET /apps HTTP/2.0" 200 5950
web_1       | 172.20.0.1 - - [11/Jan/2020:09:30:06 +0000] "GET /uploads/apps/a3/r41/icons/thumb_caa9f61575cc76aec144f10f8c28905a.png HTTP/2.0" 304 0
postgres_1  | 2020-01-11 09:30:10.287 UTC [41] FATAL:  role "root" does not exist
zealot_1    | [67b60438-0658-4192-8353-e2f78d120776] Started POST "/api/apps/upload" for 172.20.0.4 at 2020-01-11 17:30:31 +0800
zealot_1    | [67b60438-0658-4192-8353-e2f78d120776] Processing by Api::Apps::UploadController#create as */*
zealot_1    | [67b60438-0658-4192-8353-e2f78d120776]   Parameters: {"token"=>"320aaaf980e20e7b058be2d77154daaa", "channel_key"=>"6795aac6577a0cbe2c29fe1223848f6d", "file"=>#<ActionDispatch::Http::UploadedFile:0x0000557cfd28b138 @tempfile=#<Tempfile:/tmp/RackMultipart20200111-9-8h1x7o.ipa>, @original_filename="myApp.ipa", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"myApp.ipa\"\r\nContent-Length: 74186451\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: binary\r\n">, "source"=>"fastlane"}
postgres_1  | 2020-01-11 09:30:41.200 UTC [48] FATAL:  role "root" does not exist
zealot_1    | [67b60438-0658-4192-8353-e2f78d120776] [active_model_serializers] Rendered Api::UploadAppSerializer with ActiveModelSerializers::Adapter::Attributes (9.1ms)
zealot_1    | [67b60438-0658-4192-8353-e2f78d120776] Completed 201 Created in 15463ms (Views: 21.9ms | ActiveRecord: 64.9ms | Allocations: 477925)
web_1       | 172.20.0.1 - - [11/Jan/2020:09:30:46 +0000] "POST /api/apps/upload HTTP/1.1" 201 968
postgres_1  | 2020-01-11 09:31:12.253 UTC [59] FATAL:  role "root" does not exist
postgres_1  | 2020-01-11 09:31:42.891 UTC [65] FATAL:  role "root" does not exist
icyleaf commented 4 years ago

不是这个日志,这个日志是正常的,没有包含 slug 参数,再看看还有吗?

ziiip commented 4 years ago

不是很明白,上面就是没有包含 slug 参数的情况下,上传时出来的日志。但是这个上传是没有上传到正确渠道(channel_key 对应的渠道)的。

还是说,你需要包含 slug 参数情况下的日志?

icyleaf commented 4 years ago

呃,我是需要包含 slug 参数情况下的日志,这个才是报错的问题对吧?

ziiip commented 4 years ago

不好意思,我目前的认知,以为设置了 channel_key 就可以了,不用设置 slug

下面应该是你想要的了

zealot_1    | [fb2b385f-3fdd-4bc0-afeb-a8af5d18fb93] Started POST "/api/apps/upload" for 172.20.0.4 at 2020-01-11 17:58:20 +0800
zealot_1    | [fb2b385f-3fdd-4bc0-afeb-a8af5d18fb93] Processing by Api::Apps::UploadController#create as */*
zealot_1    | [fb2b385f-3fdd-4bc0-afeb-a8af5d18fb93]   Parameters: {"token"=>"320bacf980e20e7b058be2d77154dc53", "channel_key"=>"6795aac6577a0cbe2c29fe1223848f6d", "file"=>#<ActionDispatch::Http::UploadedFile:0x0000557cffa19060 @tempfile=#<Tempfile:/tmp/RackMultipart20200111-9-1pex5fs.ipa>, @original_filename="myApp.ipa", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"myApp.ipa\"\r\nContent-Length: 69593777\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: binary\r\n">, "slug"=>"bUcdE", "source"=>"fastlane"}
zealot_1    | [fb2b385f-3fdd-4bc0-afeb-a8af5d18fb93] [active_model_serializers] Rendered ActiveModel::Serializer::Null with Hash (0.13ms)
zealot_1    | [fb2b385f-3fdd-4bc0-afeb-a8af5d18fb93] Completed 422 Unprocessable Entity in 3782ms (Views: 1.4ms | ActiveRecord: 5.3ms | Allocations: 311947)
web_1       | 172.20.0.1 - - [11/Jan/2020:09:58:23 +0000] "POST /api/apps/upload HTTP/1.1" 422 68
postgres_1  | 2020-01-11 09:58:36.941 UTC [476] FATAL:  role "root" does not exist
postgres_1  | 2020-01-11 09:59:07.106 UTC [484] FATAL:  role "root" does not exist
redis_1     | 1:M 11 Jan 2020 09:59:14.040 * 100 changes in 300 seconds. Saving...
redis_1     | 1:M 11 Jan 2020 09:59:14.041 * Background saving started by pid 357
redis_1     | 357:C 11 Jan 2020 09:59:14.044 * DB saved on disk
redis_1     | 357:C 11 Jan 2020 09:59:14.044 * RDB: 0 MB of memory used by copy-on-write
redis_1     | 1:M 11 Jan 2020 09:59:14.141 * Background saving terminated with success
postgres_1  | 2020-01-11 09:59:37.294 UTC [494] FATAL:  role "root" does not exist
postgres_1  | 2020-01-11 10:00:07.488 UTC [500] FATAL:  role "root" does not exist
icyleaf commented 4 years ago

我看你传的 slug = bUcdE,这个应该是 zealot 随机生成吧?如果没有必要可以不传的,这个只是为了让 url 看起来更容易记忆而已,没有必要可以忽略该参数。如果必须设置先从 web 端设置,我检查下代码是什么问题。

web 操作的入口目前不太明显:

WX20200111-180712@2x WX20200111-180729@2x
icyleaf commented 4 years ago

设置某个渠道 channel_key 的时候,上传的位置会变成 “测试版” 渠道,非原渠道。

我的失误没从你的反馈的信息找到关键问题,这里需要说明每个渠道都是唯一的 channel_key,你使用一个渠道的 channel_key 同时又用到了另外一个渠道的 slug 上传肯定会报错的啊 😢

你需要从下图这里切换应用类型和渠道才能查看对于的渠道信息拿到 channel_key

蓝色是当前选中的应用类型和渠道,也就是说下图是测试版 Android 的渠道信息

WX20200111-181543@2x
ziiip commented 4 years ago

对,我那个 slug 是使用 zealot 自动生成的。这个没有改动。 如果这个参数不是必须的,按道理 channel_key 正确,应该就能上传到对应的渠道上。但结果却不是。 我想上传到内测版本,参数都是内测版本的,但是上传后,却到了“测试版”的渠道,而且这个渠道当初是没有的,我就保留了一个 “内测版” 的渠道,你看看下面的图 image

image

icyleaf commented 4 years ago

找到问题了,是 zealot 本身是一个 feature 的地方结果漏了一个判断造成总会创建新的渠道。 getzealot/zealot@7dc50aadf723ef89b160dde64b0bb4c188d92ba7, getzealot/zealot@0cd03ebc05415c528a656f6df33bb13d923c095e

icyleaf commented 4 years ago

zealot 应该已经发布了新的 nightly 版本,麻烦再重复下之前更新步骤吧,操作证之前建议把之前的 zealot-docker 也更新下重新 ./deploy 新的 docker 部署不再使用外部的 volumes 之后不再需要删除 volumes 从而丢失上传的应用。

另外你可以再重新 fastlane add_plugin zealot 之前失败是因为我还没发布,此次发布的版本已经加了 verify_ssl 你可以在参数中把他关闭。

icyleaf commented 4 years ago

如果考虑到上传的数据问题,我这里可以提供一个升级保留的方案:

# 复制 container 上传的数据到本地用户目录的 zealot_data
docker cp zealot_zealot_1:/app/public/uploads ~/zealot_data

经过一些 zealot-docker 初始化后在 docker-compose.yml 中 x-defaults service 下加入当前的 volumes:

x-defaults: &defaults
  restart: unless-stopped
  image: icyleafcn/zealot:nightly
  depends_on:
    redis:
      condition: service_healthy
    postgres:
      condition: service_healthy
  env_file: .env
  environment:
    ZEALOT_REDIS_HOST: redis
    ZEALOT_POSTGRES_HOST: postgres
  volumes:
    - zealot:/app
    - $(HOME)/zealot_data:/app/public/uploads
icyleaf commented 4 years ago

特别声明 因为 zealot 还未正式发布每次提交变化都会比较大感谢你的试用,我不能保证后续的变更都能过很好的保留现有的数据,但我尽可能避免这些问题

ziiip commented 4 years ago

感谢你的共享和帮助。作为一个试用者,我很明白当前的状态,我也不担心现有数据的丢失。 个人建议,最好将重要的数据,都放出来,或者注明或提供一个方式,将重要的数据映射出来。

fastlane add_plugin zealot 已经成功了。升级我要晚点才能做了,按照你提供的方式,问题应该不大。 非常非常感谢周末时间内帮助。


另外的建议: 建议管理员可以直接通过其他用户的邮箱认证,让其他用户可以不用验证就可以登录。(我还没搞好邮箱这部分,时间有点紧😂)

icyleaf commented 4 years ago

理解万岁!

我不知道是不是 LDAP 可以解决你说的用其他邮箱登陆还是说只针对 admin 账号可以自己设置?

-- /**

ziiip commented 4 years ago

理解万岁! 我不知道是不是 LDAP 可以解决你说的用其他邮箱登陆还是说只针对 admin 账号可以自己设置?

由于现在在后台添加用户(任意身份)后,该用户需要通过邮件确认后,才能登录。现在我没有配置好收发邮件部分,希望能够做到直接免除了这个确认的步骤,而且仅管理员可以使用这个免除的权利。

icyleaf commented 4 years ago

哦哦,好的。这个我再调整下

-- /**

ziiip commented 4 years ago

Nice work!