栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用Gitlab CI将每个版本部署到服务器

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用Gitlab CI将每个版本部署到服务器

您可以使用gitlab-ci和gitlab-runner [runners.ssh]部署到单个或多个服务器。

流程:

(git_project with yml file)  --> (gitlab && gitlab-ci) --> (gitlabrunner) ---runners.ssh---> (deployed_server,[deploye_server2])
  1. 您需要将gitlab-runner注册到gitlab-ci,并将标记设置为gitlab web上的delpoyServer。/etc/gitlab-runner/config.toml:
         [[runners]]      url = "http://your.gitlab.server/ci"      token = "1ba879596cf3ff778ee744e6decedd"      name = "deployServer1"      limit = 1      executor = "ssh"      builds_dir = "/data/git_build"      [runners.ssh]        user = "you_user_name"        host = "${the_destionation_of_deployServer_IP1}"        port = "22"        identity_file = "/home/you_user_name/.ssh/id_rsa"    [[runners]]      url = "http://your.gitlab.server/ci"      token = "1ba879596cf3ff778ee744e6decedd"      name = "deployServer2"      limit = 1      executor = "ssh"      builds_dir = "/data/git_build"      [runners.ssh]        user = "you_user_name"        host = "${the_destionation_of_deployServer_IP2}"        port = "22"        identity_file = "/home/you_user_name/.ssh/id_rsa"

在runner.ssh手段,亚军将登录到

${the_destionation_of_deployServer_IP1}
${the_destionation_of_deployServer_IP2}
,然后克隆项目
builds_dir

  1. 编写yml文件,例如:.gitlab-ci.yml
        job_deploy:      stage: deploy      tags: delpoyServer1      script:        -  npm install &&  forever restartall    job_deploy:      stage: deploy      tags: delpoyServer2      script:        -  npm install &&  forever restartall
  1. 将您的gitlab-runner设置为,

    delpoyServer1
    delpoyServer2
    在’ http://your.gitlab.server/ci/admin/runners ‘

    • 当您将代码推送到gitlab时
    • gitlab-ci服务器将解析
      .gitlab-ci.yml
      项目中的文件,选择带有标签的运行器:
      deployServer1
      deployServer2
      ;
    • gitlab-runner
      与deployServer1标签将登录到
      ${the_destionation_of_deployServer_IP1}
      ${the_destionation_of_deployServer_IP2}
      使用ssh,克隆该项目
      builds_dir
      ,然后执行你的脚本:NPM安装&&永远restartall。

链接:

  • gitlab-runner注册
  • 跑步者


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/430712.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号