Mac下flutter工程配置Gitlab cicd打包(暂时仅限android侧)

写的太粗糙,可能不太适合完全不懂的同学,但是实在没时间,而且也不太会写,权当做一个记录吧,对了还没有搞docker这些,还在持续学习中

1.GitLab Runner(打包机)

注意:需要有对应的权限,才能对GitLab进行配置

进入具体的项目 -> Settings -> CI/CD -> Runners -> Specific Runners

别人的是这样,我的不太一样,但是找还是能找到token在哪里

安装地址:

Install GitLab Runner | GitLab

注册教程:

Registering runners | GitLab

2、进行注册

方式一:交互式注册

官方步骤:注册 Runner

  • 注册过程中,你需要提供以下信息:

  • GitLab服务器的URL:输入你的GitLab服务器的URL。 如:https://gitlab.com/

  • Runner注册的Token:在GitLab项目的设置中,找到"CI/CD">"Runners"页面,复制"Specific Runner Token"。找管理员要或者自己看(如果有权限的话)

  • Runner的描述:输入一个描述此Runner的名称。

  • Runner的标签:可以选择为Runner添加标签,用于在GitLab CI/CD配置中选择特定的Runner。这个标签tag很重要,需要记录下来。

  • Runner的执行器:选择适合你的环境的执行器,如shell、docker、docker+machine等。此处填shell。

  • 完成注册后,Runner将与GitLab服务器建立连接。

配置Runner:

  • 注册成功后,可以在GitLab项目的设置中的"CI/CD">"Runners"页面查看和配置Runner。

  • 可以为Runner配置特定的标签、并发构建数、执行器选项等。

启动Runner:

  • 在终端或命令提示符中,运行以下命令启动Runner:

sudo gitlab-runner start

注:我的使用上面命令会报错,使用sudo gitlab-runner run成功

复制代码
[root@run01 ~]# gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=3293 revision=f767c145 version=15.3.3
Running in system-mode.                            
                                                   
Enter the GitLab instance URL (for example, https://gitlab.com/):
http://192.168.170.133/
Enter the registration token:
GR1348941sUxNyye1qD4HcTSW-TMw
Enter a description for the runner:
[run01]: test
Enter tags for the runner (comma-separated):
build
Enter optional maintenance note for the runner:
this is d test
Registering runner... succeeded                     runner=GR1348941sUxNyye1
Enter an executor: custom, parallels, shell, docker-ssh+machine, docker, docker-ssh, ssh, virtualbox, docker+machine, kubernetes:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
 
Configuration (with the authentication token) was saved in "/etc/gitlab-runner/config.toml" 

3、最最最简单的脚本配置

.gitlab-ci.yml里面的内容:

复制代码
stages:
  - build

variables:
  ANDROID_APP_NAME: "flutterDemo"   # Android 应用的名称
  ANDROID_PACKAGE_NAME: "com.demo.flutter_demo" # Android 应用的包名

build_android_apk:
  stage: build
  script:
    - flutter clean
    - flutter build apk
  tags:
    - build
  artifacts:
    paths:
      - build/app/outputs/flutter-apk/flutter_demo.apk
#    only:
#      - main  # 配置只有 main 分支触发构建

记得android目录下配置kestore文件相关的内容。

打包成功的截图如下:

相关推荐
爱吃香蕉的阿豪12 小时前
Mac 远程操作 Windows 开发:ZeroTier + JetBrains 实战指南
windows·macos·zerotoer
大嘴皮猴儿1 天前
从零开始学商品图翻译:小白也能快速掌握的多语言文字处理与上架技巧
大数据·ide·人工智能·macos·新媒体运营·xcode·自动翻译
空中海1 天前
第六章:iOS导航与路由系统
macos·ios·cocoa
空中海1 天前
第九章:iOS系统框架与能力
macos·ios·cocoa
大棉花哥哥1 天前
MAC下JADX+MCP+OpenCode自动APK逆向分析
macos·ai
空中海1 天前
第八章:iOS并发编程
macos·ios·cocoa
算是难了1 天前
macOS常用终端命令
macos
小码过河.2 天前
本地端侧GUI智能体自动化操作电脑Mano-P:macOS版本安装与使用全指南
macos·ai·自动化
空中海2 天前
第十章:iOS架构设计与工程化
macos·ios·cocoa
香蕉鼠片2 天前
跨平台开发到底是什么
linux·windows·macos