• git提交代码自动部署,git-runner


    基于CI/CD方式,使用git-runner 工具实现代码提交即发布。简化发布流程。个人感觉比 jinekngs 好用

    我是Linux服务器

    第1步:先安装git-runner。

    安装:git-runner   https://www.freesion.com/article/65101298227/
    8、echo “export PATH=$PATH:/usr/local/git/bin” >> /etc/bashrc
    9、source /etc/bashrc
    10、git —version
    
    安装git-runner:
    1.下载安装包   sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/v12.8.0/binaries/gitlab-runner-linux-amd64
    2. sudo chmod 777 /usr/local/bin/gitlab-runner
    3.安装  gitlab-runner install --user=root --working-directory=/home/gitlab-runner
    4.启动  gitlab-runner start
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    第2步:安装git

    1.	官网下载: wget https://Github.com/Git/Git/archive/v2.11.0.tar.gz
    2.	解压:tar -zxvf git-2.11.0.tar.gz
    3.	cd git-2.11.0
    4.	yum install libcurl-devel
    5.	移除旧版本git:yum remove git
    6.	make configure
    如果报错/bin/sh: autoconf: command not found:
    
    安装libtool即可:yum install autoconf automake libtool
    
    正常会打印:GEN configure
    
    执行
    7.	./configure —prefix=/usr/local/git —with-iconv —with-curl —with-expat=/usr/local/lib
    make && make install
    
    ①如果报错:cache.h:40:18: fatal error: zlib.h: No such file or directory
    
    安装zlib:yum install zlib、yum install zlib-devel
    
    ②如果报错:make[1]: *** [perl.mak] Error 2
    make: *** [perl/perl.mak] Error 2
    
    安装:yum install perl-ExtUtils-MakeMaker package
     
    安装:git-runner   https://www.freesion.com/article/65101298227/
    8、echo “export PATH=$PATH:/usr/local/git/bin” >> /etc/bashrc
    9、source /etc/bashrc
    10、git —version
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30

    第3步:安装npm ,网上文档很多,可以随便找
    配置淘宝镜像

    npm config set registry https://registry.npm.taobao.org
    
    • 1

    第4步:注册git-runner到 你的 git仓库。,这里需要仓库的 ip和 Token,再仓库里设置(需要管理员权限),CI/CD 处可以找到。

    # 注册
    1.gitlab-runner register
    # 输入本地的 gitlab URL
    2.Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com )
    https://mesgit.seagate.com/
    # 输入 Token
    3.Please enter the gitlab-ci token for this runner
    _FTHYNTYU747RzxFCYG
    # 输入 tag, 注意要跟 job 的 tag 一致
    4.Please enter the gitlab-ci tags for this runner (comma separated):
    my-tag,another-tag
    # 选择 executor,有docker选dokcer,没有选shell 
    5.Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:
    shell# 输入 Token
    6.Please enter the gitlab-ci token for this runner
    _FTHYNTYU747RzxFCYG
    # 输入 tag, 注意要跟 job 的 tag 一致
    7.Please enter the gitlab-ci tags for this runner (comma separated):
    my-tag,another-tag
    # 选择 executor,有docker选dokcer,没有选shell
    8.Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:
    shell
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23

    第5步:再git仓库里,新建gitlab-ci.yml 脚本。保存。 到这里就完毕了。
    https://www.jianshu.com/p/4cc441b1c8a3
    写yml的文档。可以参考。

  • 相关阅读:
    Github 2FA绑定中国+86手机号码实现两步验证
    【C++11】shared_ptr
    Vscode远程调试及gdbserver配置
    springboot整合redis-sentinel哨兵模式集群(二)
    加密与安全_探索签名算法
    【云原生kubernetes系列】--RBAC权限的使用
    基础课13——数据异常处理
    WSDM‘23 推荐系统论文梳理
    训练千亿参数大模型,离不开四种GPU并行策略
    数字文创产权版权登记保护多少重要
  • 原文地址:https://blog.csdn.net/ninth_spring/article/details/127571497