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文件相关的内容。

打包成功的截图如下:

相关推荐
humiaor5 小时前
Xcode报错:“Set `maskView` to `nil` before adding it as a subview of ZFMaskView
ide·macos·xcode·ios18报错
Decadent丶沉沦11 小时前
mac-M系列芯片安装软件报错:***已损坏,无法打开。推出磁盘问题
macos
SoraLuna14 小时前
「Mac畅玩AIGC与多模态41」开发篇36 - 用 ArkTS 构建聚合搜索前端页面
前端·macos·aigc
有梦想的攻城狮15 小时前
mac本地docker镜像上传指定虚拟机
macos·docker·eureka
深井冰水17 小时前
Pycharm的终端执行allure命令出现command not found
macos·pycharm·接口自动化
黄昏贩卖机17 小时前
mac latex vscode 配置
ide·vscode·macos
亚林瓜子1 天前
pyenv简单的Python版本管理器(macOS版)
开发语言·python·macos·pyenv
joinclear1 天前
【问题记录】08 MAC电脑,安装HP打印机驱动,提示:此更新需要macOS版本15.0或更低版本
macos·hp打印机
SoraLuna1 天前
「Mac畅玩AIGC与多模态40」开发篇35 - 用 Python 开发服务对接 SearxNG 与本地知识库
python·macos·aigc
WuYiCheng6662 天前
TLS 1.3黑魔法:从协议破解到极致性能调优
macos