首页 > 解决方案 > 自动将 gitlab 管道与 azure Web 服务连接

问题描述

我在 GitLab 上有我的 webapp 代码。我想使用 Azure Web 服务部署它。但我希望它这样,当我将代码推送到分支时,它将首先被推送到 GitLab,然后自动推送到 azure Web 服务上。有没有办法做到这一点?我在互联网上搜索了解决方案,但没有找到最新的解决方案。

标签: djangoazureazure-devopsgitlabazure-web-app-service

解决方案


在 Azure 上设置 Gitlab Continuous (CI/CD)

使用 Docker 引擎部署 Ubuntu VM

  1. 转到https://gitlab.com/daveRendon/ubuntu-vm-with-docker-engine/blob/master/README.md并部署到 Azure
  2. 提供虚拟机参数,点击购买
  3. 配置 VM 后,转到 VM 配置并将 IP 地址更改为静态
  4. 使用 SSH 连接到虚拟机

设置 Gitlab

  1. 通过 SSH 连接到 Ubuntu 虚拟机

  2. 安装和配置必要的依赖项

  3. sudo apt-get 更新

  4. sudo apt-get install -y curl openssh-server ca-certificates

  5. 安装后缀

  6. sudo apt-get install -y 后缀

  7. 在 Postfix 安装期间,可能会出现一个配置屏幕。选择“Internet 站点”并按 Enter。使用您服务器的外部 DNS 作为“邮件名称”,然后按 Enter。如果出现其他屏幕,请继续按 Enter 以接受默认值

  8. 添加 GitLab 包存储库

  9. 卷曲https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | 须藤重击

  10. 安装 GitLab 包。将https://gitlab.example.com更改为您要访问 GitLab 实例的 URL。

  11. sudo EXTERNAL_URL=" https://gitlab.example.com " apt-get install gitlab-ee

  12. 浏览到主机名并使用默认帐户的用户名 root 登录

  13. 在这种情况下> http://gitlabs.eastus.cloudapp.azure.com

在 azure 上部署 webapp

  1. 使用 Azure 门户部署 ARM 模板:

  2. https://gitlab.com/daveRendon/ifreeze/blob/master/webapp.js

  3. 在 Azure 上创建 Gitlab 项目

  4. 访问 Azure 上的 Gitlab

  5. http://gitlabs.eastus.cloudapp.azure.com

  6. 创建新项目

  7. 生成您的 SSH 密钥

  8. https://gitlab.com/help/ssh/README#generating-a-new-ssh-key-pair

在 Azure 上设置 Gitlab Continuous (CI/CD)

  1. 转到 Azure Web 应用
  2. 选择部署中心
  3. 选择源代码控制“外部”,然后单击继续
  4. 现在在 Build Provider 中选择“App Service Build Service”
  5. 添加 Gitlab URL 和 master 分支
  6. 在选择 Private Repository “YES” 并提供凭据,在这种情况下,用户 root 和先前创建的密码
  7. 测试在 Azure 上运行的 Gitlab 项目的更改,检查此处gitlab Continuous ci/cd with an azure web app

参考这里


推荐阅读