# GitLab CI/CD Examples

> 原文：[https://docs.gitlab.com/ee/ci/examples/README.html](https://docs.gitlab.com/ee/ci/examples/README.html)

*   [CI/CD examples](#cicd-examples)
    *   [Contributing examples](#contributing-examples)
*   [CI/CD templates](#cicd-templates)
    *   [Adding templates to your GitLab installation](#adding-templates-to-your-gitlab-installation-premium-only)
*   [Other resources](#other-resources)
    *   [CI/CD in the cloud](#cicd-in-the-cloud)
    *   [Customer stories](#customer-stories)
    *   [Getting started](#getting-started)
    *   [Implementing GitLab CI/CD](#implementing-gitlab-cicd)
    *   [Migrating to GitLab from third-party CI tools](#migrating-to-gitlab-from-third-party-ci-tools)
    *   [Integrating GitLab CI/CD with other systems](#integrating-gitlab-cicd-with-other-systems)
    *   [Mobile development](#mobile-development)

# GitLab CI/CD Examples[](#gitlab-cicd-examples "Permalink")

该页面包含指向各种示例的链接，这些示例可以帮助您了解如何针对特定用例实现[GitLab CI / CD](../README.html) .

示例有几种形式. 作为以下内容的集合：

*   在 GitLab 中维护的`.gitlab-ci.yml` [模板文件](#cicd-templates) ，用于许多常见的框架和编程语言.
*   具有各种语言[示例项目的](https://gitlab.com/gitlab-examples)存储库. 您可以分叉并根据自己的需要进行调整. 项目包括[多项目管道的](https://gitlab.com/gitlab-examples/multi-project-pipelines)演示以及[在 NGINX 服务的静态站点上](https://gitlab.com/gitlab-examples/review-apps-nginx/)使用[Review Apps](https://gitlab.com/gitlab-examples/review-apps-nginx/) .
*   下面列出了示例和[其他资源](#other-resources) .

## CI/CD examples[](#cicd-examples "Permalink")

下表列出了本节中包含分步教程的示例.

| 用例 | Resource |
| --- | --- |
| 浏览器性能测试 | [Browser Performance Testing with the Sitespeed.io container](../../user/project/merge_requests/browser_performance_testing.html). |
| 负载性能测试 | [Load Performance Testing with the k6 container](../../user/project/merge_requests/load_performance_testing.html). |
| Clojure | [Test a Clojure application with GitLab CI/CD](test-clojure-application.html). |
| 使用 Dpl 进行部署 | [Using `dpl` as deployment tool](deployment/README.html). |
| Elixir | [Testing a Phoenix application with GitLab CI/CD](test_phoenix_app_with_gitlab_ci_cd/index.html). |
| 端到端测试 | [End-to-end testing with GitLab CI/CD and WebdriverIO](end_to_end_testing_webdriverio/index.html). |
| Game development | [DevOps and Game Dev with GitLab CI/CD](devops_and_game_dev_with_gitlab_ci_cd/index.html). |
| GitLab 页面 | 有关部署静态站点的完整示例，请参见[GitLab Pages](../../user/project/pages/index.html)文档. |
| 带有 Spring Boot 的 Java | [Deploy a Spring Boot application to Cloud Foundry with GitLab CI/CD](deploy_spring_boot_to_cloud_foundry/index.html). |
| Java 与 Maven | [How to deploy Maven projects to Artifactory with GitLab CI/CD](artifactory_and_gitlab/index.html). |
| PHP 与 PHPunit，Atoum | [Testing PHP projects](php.html). |
| PHP 与 NPM，SCP | [Running Composer and NPM scripts with deployment via SCP in GitLab CI/CD](deployment/composer-npm-deploy.html). |
| PHP 与 Laravel，Envoy | [Test and deploy Laravel applications with GitLab CI/CD and Envoy](laravel_with_gitlab_and_envoy/index.html). |
| Heroku 上的 Python | [Test and deploy a Python application with GitLab CI/CD](test-and-deploy-python-application-to-heroku.html). |
| 红宝石在 Heroku 上 | [Test and deploy a Ruby application with GitLab CI/CD](test-and-deploy-ruby-application-to-heroku.html). |
| Heroku 上的 Scala | [Test and deploy a Scala application to Heroku](test-scala-application.html). |
| 并行测试 Ruby 和 JS | [GitLab CI/CD parallel jobs testing for Ruby & JavaScript projects](https://docs.knapsackpro.com/2019/how-to-run-parallel-jobs-for-rspec-tests-on-gitlab-ci-pipeline-and-speed-up-ruby-javascript-testing). |
| Vault 的秘密管理 | [Authenticating and Reading Secrets With Hashicorp Vault](authenticating-with-hashicorp-vault/index.html). |

### Contributing examples[](#contributing-examples "Permalink")

欢迎捐款！ 您可以通过发送合并请求和该语言的指南来帮助您最喜欢的编程语言用户和 GitLab.

## CI/CD templates[](#cicd-templates "Permalink")

使用`.gitlab-ci.yml` [模板](https://gitlab.com/gitlab-org/gitlab/tree/master/lib/gitlab/ci/templates)开始使用 GitLab CI / CD 和您喜欢的编程语言或框架.

在用户界面中创建`gitlab-ci.yml`文件时，可以选择以下模板之一：

*   [Android (`Android.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Android.gitlab-ci.yml)
*   [Android with fastlane (`Android-Fastlane.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml)
*   [Bash (`Bash.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Bash.gitlab-ci.yml)
*   [C++ (`C++.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/C++.gitlab-ci.yml)
*   [Chef (`Chef.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Chef.gitlab-ci.yml)
*   [Clojure (`Clojure.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Clojure.gitlab-ci.yml)
*   [Composer `Composer.gitlab-ci.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Composer.gitlab-ci.yml)
*   [Crystal (`Crystal.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Crystal.gitlab-ci.yml)
*   [Django (`Django.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Django.gitlab-ci.yml)
*   [Docker (`Docker.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Docker.gitlab-ci.yml)
*   [dotNET (`dotNET.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/dotNET.gitlab-ci.yml)
*   [dotNET Core (`dotNET-Core.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/dotNET-Core.yml)
*   [Elixir (`Elixir.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Elixir.gitlab-ci.yml)
*   [goLang (`Go.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Go.gitlab-ci.yml)
*   [Gradle (`Gradle.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Gradle.gitlab-ci.yml)
*   [Grails (`Grails.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Grails.gitlab-ci.yml)
*   [iOS with fastlane (`iOS-Fastlane.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/iOS-Fastlane.gitlab-ci.yml)
*   [Julia (`Julia.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Julia.gitlab-ci.yml)
*   [Laravel (`Laravel.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Laravel.gitlab-ci.yml)
*   [LaTeX (`LaTeX.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/LaTeX.gitlab-ci.yml)
*   [Maven (`Maven.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Maven.gitlab-ci.yml)
*   [Mono (`Mono.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Mono.gitlab-ci.yml)
*   [NPM (`npm.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/npm.gitlab-ci.yml)
*   [Node.js (`Nodejs.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Nodejs.gitlab-ci.yml)
*   [OpenShift (`OpenShift.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/OpenShift.gitlab-ci.yml)
*   [Packer (`Packer.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Packer.gitlab-ci.yml)
*   [PHP (`PHP.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/PHP.gitlab-ci.yml)
*   [Python (`Python.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml)
*   [Ruby (`Ruby.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Ruby.gitlab-ci.yml)
*   [Rust (`Rust.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Rust.gitlab-ci.yml)
*   [Scala (`Scala.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Scala.gitlab-ci.yml)
*   [Swift (`Swift.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Swift.gitlab-ci.yml)
*   [Terraform (`Terraform.gitlab-ci.yml`)](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Terraform.gitlab-ci.yml)

如果编程语言或框架模板不在此列表中，则可以提供一种. 要创建模板，请向[https://gitlab.com/gitlab-org/gitlab/tree/master/lib/gitlab/ci/templates](https://gitlab.com/gitlab-org/gitlab/tree/master/lib/gitlab/ci/templates)提交合并请求.

### Adding templates to your GitLab installation[](#adding-templates-to-your-gitlab-installation-premium-only "Permalink")

您可以将自定义示例和模板添加到自我管理的 GitLab 实例. 您的 GitLab 管理员可以[指定一个实例模板存储库](../../user/admin_area/settings/instance_template_repository.html) ，其中包含特定于您组织的示例和模板.

## Other resources[](#other-resources "Permalink")

本节提供更多资源，以帮助您熟悉 GitLab CI / CD 的各种用法. 请注意，较早的文章和视频可能无法反映最新的 GitLab 版本的状态.

### CI/CD in the cloud[](#cicd-in-the-cloud "Permalink")

有关为基于云的环境设置 GitLab CI / CD 的示例，请参见：

*   [How to set up multi-account AWS SAM deployments with GitLab CI](https://about.gitlab.com/blog/2019/02/04/multi-account-aws-sam-deployments-with-gitlab-ci/)
*   [Automating Kubernetes Deployments with GitLab CI/CD](https://www.youtube.com/watch?v=wEDRfAz6_Uw)
*   [How to autoscale continuous deployment with GitLab Runner on DigitalOcean](https://about.gitlab.com/blog/2018/06/19/autoscale-continuous-deployment-gitlab-runner-digital-ocean/)
*   [How to create a CI/CD pipeline with Auto Deploy to Kubernetes using GitLab and Helm](https://about.gitlab.com/blog/2017/09/21/how-to-create-ci-cd-pipeline-with-autodeploy-to-kubernetes-using-gitlab-and-helm/)
*   [Demo - Deploying from GitLab to OpenShift Container Cluster](https://youtu.be/EwbhA53Jpp4)

另请参阅以下视频概述：

*   [Kubernetes, GitLab, and Cloud Native](https://www.youtube.com/watch?v=d-9awBxEbvQ).
*   [Deploying to IBM Cloud with GitLab CI/CD](https://www.youtube.com/watch?v=6ZF4vgKMd-g).

### Customer stories[](#customer-stories "Permalink")

有关使用 GitLab CI / CD 的一些客户体验，请参阅：

*   [How Verizon Connect reduced datacenter deploys from 30 days to under 8 hours with GitLab](https://about.gitlab.com/blog/2019/02/14/verizon-customer-story/)
*   [How Wag! cut their release process from 40 minutes to just 6](https://about.gitlab.com/blog/2019/01/16/wag-labs-blog-post/)
*   [How Jaguar Land Rover embraced CI to speed up their software lifecycle](https://about.gitlab.com/blog/2018/07/23/chris-hill-devops-enterprise-summit-talk/)

### Getting started[](#getting-started "Permalink")

有关帮助您入门的一些示例，请参阅：

*   [GitLab CI/CD’s 2018 highlights](https://about.gitlab.com/blog/2019/01/21/gitlab-ci-cd-features-improvements/)
*   [A beginner’s guide to continuous integration](https://about.gitlab.com/blog/2018/01/22/a-beginners-guide-to-continuous-integration/)

### Implementing GitLab CI/CD[](#implementing-gitlab-cicd "Permalink")

有关其他已实施 GitLab CI / CD 的示例，请参见：

*   [How to streamline interactions between multiple repositories with multi-project pipelines](https://about.gitlab.com/blog/2018/10/31/use-multiproject-pipelines-with-gitlab-cicd/)
*   [How we used GitLab CI to build GitLab faster](https://about.gitlab.com/blog/2018/05/02/using-gitlab-ci-to-build-gitlab-faster/)
*   [Test all the things in GitLab CI with Docker by example](https://about.gitlab.com/blog/2018/02/05/test-all-the-things-gitlab-ci-docker-examples/)
*   [A Craftsman looks at continuous integration](https://about.gitlab.com/blog/2018/01/17/craftsman-looks-at-continuous-integration/)
*   [Go tools and GitLab: How to do continuous integration like a boss](https://about.gitlab.com/blog/2017/11/27/go-tools-and-gitlab-how-to-do-continuous-integration-like-a-boss/)
*   [GitBot – automating boring Git operations with CI](https://about.gitlab.com/blog/2017/11/02/automating-boring-git-operations-gitlab-ci/)
*   [How to use GitLab CI for Vue.js](https://about.gitlab.com/blog/2017/09/12/vuejs-app-gitlab/)
*   Video: [GitLab CI/CD Deep Dive](https://youtu.be/pBe4t1CD8Fc?t=195)
*   [Dockerizing GitLab Review Apps](https://about.gitlab.com/blog/2017/07/11/dockerizing-review-apps/)
*   [Fast and natural continuous integration with GitLab CI](https://about.gitlab.com/blog/2017/05/22/fast-and-natural-continuous-integration-with-gitlab-ci/)
*   [Demo: CI/CD with GitLab in action](https://about.gitlab.com/blog/2017/03/13/ci-cd-demo/)

### Migrating to GitLab from third-party CI tools[](#migrating-to-gitlab-from-third-party-ci-tools "Permalink")

*   [Migrating from Jenkins to GitLab](https://youtu.be/RlEVGOpYF5Y)

### Integrating GitLab CI/CD with other systems[](#integrating-gitlab-cicd-with-other-systems "Permalink")

要查看如何将 GitLab CI / CD 与第三方系统集成，请参阅：

*   [Streamline and shorten error remediation with Sentry’s new GitLab integration](https://about.gitlab.com/blog/2019/01/25/sentry-integration-blog-post/)
*   [How to simplify your smart home configuration with GitLab CI/CD](https://about.gitlab.com/blog/2018/08/02/using-the-gitlab-ci-slash-cd-for-smart-home-configuration-management/)
*   [Demo: GitLab + Jira + Jenkins](https://about.gitlab.com/blog/2018/07/30/gitlab-workflow-with-jira-jenkins/)
*   [Introducing Auto Breakfast from GitLab (sort of)](https://about.gitlab.com/blog/2018/06/29/introducing-auto-breakfast-from-gitlab/)

### Mobile development[](#mobile-development "Permalink")

有关使用 GitLab CI / CD 进行移动应用程序开发的帮助，请参阅：

*   [How to publish Android apps to the Google Play Store with GitLab and fastlane](https://about.gitlab.com/blog/2019/01/28/android-publishing-with-gitlab-and-fastlane/)
*   [Setting up GitLab CI for Android projects](https://about.gitlab.com/blog/2018/10/24/setting-up-gitlab-ci-for-android-projects/)
*   [Working with YAML in GitLab CI from the Android perspective](https://about.gitlab.com/blog/2017/11/20/working-with-yaml-gitlab-ci-android/)
*   [How to use GitLab CI and MacStadium to build your macOS or iOS projects](https://about.gitlab.com/blog/2017/05/15/how-to-use-macstadium-and-gitlab-ci-to-build-your-macos-or-ios-projects/)
*   [Setting up GitLab CI for iOS projects](https://about.gitlab.com/blog/2016/03/10/setting-up-gitlab-ci-for-ios-projects/)