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

打包成功的截图如下:

相关推荐
liliangcsdn1 小时前
smolagents - 如何在mac用agents做简单算术题
人工智能·macos·prompt
名字不要太长 像我这样就好2 小时前
【iOS】继承链
macos·ios·cocoa
潜龙95273 小时前
第4.3节 iOS App生成追溯关系
macos·ios·cocoa
玄辰星君12 小时前
【MAC】nacos 2.5.1容器docker安装
macos·docker·nacos
atwdy17 小时前
MacOS安装linux虚拟机
linux·运维·ubuntu·macos·utm
echola_mendes18 小时前
Dify:在MacOS系统下Dify的本地部署与使用
macos
Tim风声(网络工程师)18 小时前
如何通过mac的前24bit,模糊确认是那一台什么样的设备
运维·服务器·网络·macos
菜鸟555551 天前
河南萌新联赛2025第一场-河南工业大学
macos·objective-c·cocoa
名字不要太长 像我这样就好2 天前
【iOS】源码阅读(六)——方法交换
开发语言·macos·ios·objective-c·cocoa
Digitally2 天前
轻松将文件从 iPhone 传输到 Mac
macos·ios·iphone