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

打包成功的截图如下:

相关推荐
Benny的老巢2 小时前
Mac上用XAMPP搭建局域网可访问的开发环境,让局域网内其他设备通过域名访问
nginx·macos·apache·xampp·php开发环境
2501_941881409 小时前
在墨西哥城复杂流量环境下构建高稳定性API网关的架构设计与实现实践分享
macos·golang·xcode
wadesir10 小时前
macOS Sequoia与macOS Tahoe全面对比:功能、性能与升级教程(新手入门指南)
macos
FreeBuf_13 小时前
新型TCC绕过漏洞:macOS面临自动化攻击风险
macos·自动化·策略模式
Alice13 小时前
Remote control Mac ios
macos
huaiyanchen13 小时前
mac Navicat 下载及安装
macos
人生何处不修行14 小时前
iOS 自定义视频播放器实战:全屏旋转 + 画中画(PiP)+ 多页面切换不中断播放
macos·objective-c·cocoa
梁辰兴1 天前
计算机网络基础:MAC 地址
计算机网络·macos·计算机·mac地址·计算机网络基础·梁辰兴·物理地址
酒书1 天前
mac电脑idea更改git用户名和密码
git·macos·intellij-idea
科技智驱1 天前
格式化数据分区会清除哪些数据?Windows/Mac如何正确格式化
windows·macos·电脑