<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Introduction to CI/CD with GitLab > 原文:[https://docs.gitlab.com/ee/ci/introduction/](https://docs.gitlab.com/ee/ci/introduction/) * [Introduction to CI/CD methodologies](#introduction-to-cicd-methodologies) * [Continuous Integration](#continuous-integration) * [Continuous Delivery](#continuous-delivery) * [Continuous Deployment](#continuous-deployment) * [Introduction to GitLab CI/CD](#introduction-to-gitlab-cicd) * [How GitLab CI/CD works](#how-gitlab-cicd-works) * [Basic CI/CD workflow](#basic-cicd-workflow) * [A deeper look into the CI/CD basic workflow](#a-deeper-look-into-the-cicd-basic-workflow) * [Setting up GitLab CI/CD for the first time](#setting-up-gitlab-cicd-for-the-first-time) # Introduction to CI/CD with GitLab[](#introduction-to-cicd-with-gitlab "Permalink") 在本文檔中,我們將概述持續集成,持續交付和持續部署的概念,并介紹 GitLab CI / CD. **開箱即用的管理系統可以將維護工具鏈所花費的時間減少 10%或更多.** 觀看我們的["精通持續軟件開發"](https://about.gitlab.com/webcast/mastering-ci-cd/)網絡廣播,以了解連續方法以及 GitLab 的內置 CI 如何幫助您簡化和擴展軟件開發. ## Introduction to CI/CD methodologies[](#introduction-to-cicd-methodologies "Permalink") 軟件開發的連續方法基于自動執行腳本,以最大程度地減少在開發應用程序時引入錯誤的機會. 從開發新代碼到部署新代碼,他們幾乎不需要人工干預,甚至根本不需要干預. 它涉及到在每次小的迭代中就不斷地構建,測試和部署代碼更改,從而減少了基于錯誤或失敗的先前版本開發新代碼的機會. 此方法有三種主要方法,每種方法都將根據最適合您的策略的方式進行應用. ### Continuous Integration[](#continuous-integration "Permalink") 考慮一個應用程序,其代碼存儲在 GitLab 的 Git 存儲庫中. 開發人員每天要多次推送代碼更改. 對于每次向存儲庫的推送,您都可以創建一組腳本來自動構建和測試您的應用程序,從而減少了向應用程序引入錯誤的機會. 這種做法被稱為[持續整合](https://en.wikipedia.org/wiki/Continuous_integration) ; 對于提交給應用程序(甚至是開發分支)的每個更改,它都會自動連續地構建和測試,以確保所引入的更改通過您為應用程序建立的所有測試,準則和代碼合規性標準. [GitLab 本身](https://gitlab.com/gitlab-org/gitlab-foss)就是使用持續集成作為軟件開發方法的一個示例. 對于項目的每一次推送,都有一組檢查腳本的腳本. ### Continuous Delivery[](#continuous-delivery "Permalink") [持續交付](https://continuousdelivery.com/)是超越持續集成的一步. 您的應用程序不僅會在推送到代碼庫的每次代碼更改時都進行構建和測試,而且作為附加步驟,盡管部署是手動觸發的,但它仍會持續部署. 此方法可確保自動檢查代碼,但需要人工干預才能從策略上手動觸發更改的部署. ### Continuous Deployment[](#continuous-deployment "Permalink") 類似于持續交付, [持續部署](https://www.airpair.com/continuous-deployment/posts/continuous-deployment-for-practical-people)也是超越持續集成的又一步. 區別在于,您無需將其手動部署,而是將其設置為自動部署. 部署您的應用程序完全不需要人工干預. ## Introduction to GitLab CI/CD[](#introduction-to-gitlab-cicd "Permalink") GitLab CI / CD 是內置在 GitLab 中的功能強大的工具,它使您可以將所有連續方法(連續集成,交付和部署)應用于軟件,而無需第三方應用程序或集成. 有關概述,請參閱最近的 GitLab 聚會中的[GitLab CI 簡介](https://www.youtube.com/watch?v=l5705U8s_nQ&t=397) . ### How GitLab CI/CD works[](#how-gitlab-cicd-works "Permalink") 要使用 GitLab CI / CD,您需要做的是托管在 Git 存儲庫中的應用程序代碼庫,并在[`.gitlab-ci.yml`](../yaml/README.html)文件中指定生成,測試和部署腳本,該文件位于以下目錄的根路徑中:您的存儲庫. 在此文件中,您可以定義要運行的腳本,定義包含和緩存依賴項,選擇要按順序運行的命令和要并行運行的命令,定義要在哪里部署應用程序,以及指定是否將要自動運行腳本或手動觸發任何腳本. 熟悉 GitLab CI / CD 后,您可以在配置文件中添加更多高級步驟. 要將腳本添加到該文件,您需要按照適合您的應用程序并符合您要執行的測試的順序來組織它們. 為了可視化該過程,假設添加到配置文件中的所有腳本與在計算機的終端上運行的命令相同. 將`.gitlab-ci.yml`配置文件添加到存儲庫后,GitLab 將檢測到該文件并使用名為[GitLab Runner](https://docs.gitlab.com/runner/)的工具運行腳本,該工具的操作與終端類似. 這些腳本被分組為**作業** ,它們共同組成了一個**管道** . `.gitlab-ci.yml`文件的一個簡約示例可以包含: ``` before_script: - apt-get install rubygems ruby-dev -y run-test: script: - ruby --version ``` `before_script`屬性將在運行任何內容之前為您的應用程序安裝依賴項,并且名為`run-test`的**作業**將打印當前系統的 Ruby 版本. 它們兩者都構成了在每次推送到存儲庫的任何分支時觸發的**管道** . GitLab CI / CD 不僅執行您已設置的作業,而且還向您顯示執行期間發生的事情,就像您在終端中看到的那樣: [![job running](https://img.kancloud.cn/46/4a/464a5bdf1e9d648b017f70ee2c6e504d_3356x1844.png)](img/job_running.png) 您為您的應用程序創建了策略,GitLab 根據您定義的內容為您運行管道. 您的管道狀態也會由 GitLab 顯示: [![pipeline status](https://img.kancloud.cn/d9/d5/d9d5958f19b8b788d977156653814803_2870x500.png)](img/pipeline_status.png) 最后,如果出現任何問題,您可以輕松[回滾](../environments/index.html#retrying-and-rolling-back)所有更改: [![rollback button](https://img.kancloud.cn/9e/a7/9ea770449b25ac3128f01dd829ffbd5d_2872x569.png)](img/rollback.png) ### Basic CI/CD workflow[](#basic-cicd-workflow "Permalink") 考慮以下示例,以了解 GitLab CI / CD 如何適合通用開發工作流程. 假設您已在一個問題中討論了代碼實現,并在本地進行了建議的更改. 將提交推送到 GitLab 中的遠程存儲庫中的功能分支后,將觸發項目的 CI / CD 管道集. 這樣,GitLab CI / CD: * 運行自動化腳本(順序或并行)以: * 構建并測試您的應用. * 就像在`localhost`看到的那樣,使用 Review Apps 預覽每個合并請求的更改. 對實施感到滿意后: * 讓您的代碼得到審查和批準. * 將功能分支合并到默認分支. * GitLab CI / CD 將您的更改自動部署到生產環境. * 最后,如果出現問題,您和您的團隊可以輕松地將其回滾. [![GitLab workflow example](https://img.kancloud.cn/61/fc/61fc6abe9ef94aa95fc7193c33bfcfbf_3420x1894.png)](img/gitlab_workflow_example_11_9.png) GitLab CI / CD 可以做更多的事情,但是此工作流程體現了 GitLab 跟蹤整個過程的能力,而無需使用外部工具來交付軟件. 而且,最有用的是,您可以通過 GitLab UI 可視化所有步驟. #### A deeper look into the CI/CD basic workflow[](#a-deeper-look-into-the-cicd-basic-workflow "Permalink") 如果我們深入研究基本工作流程,則可以在 DevOps 生命周期的每個階段看到 GitLab 中可用的功能,如下圖所示. [![Deeper look into the basic CI/CD workflow](https://img.kancloud.cn/96/12/9612292aae51f6ca271c13f4b36379fb_1692x1068.png)](img/gitlab_workflow_example_extended_v12_3.png) 如果您從左至右查看圖像,則會根據每個階段(驗證,打包,發布)看到 GitLab 中的一些可用功能. 1. **Verify**: * 通過持續集成自動構建和測試您的應用程序. * 使用[GitLab 代碼質量](../../user/project/merge_requests/code_quality.html)分析您的源代碼[質量](../../user/project/merge_requests/code_quality.html) . * 使用[瀏覽器性能測試](../../user/project/merge_requests/browser_performance_testing.html)確定代碼更改對性能的影響. * 執行一系列測試,例如[容器掃描](../../user/application_security/container_scanning/index.html) , [依賴掃描](../../user/application_security/dependency_scanning/index.html) 和[JUnit 測試](../junit_test_reports.html) . * 使用[Review Apps](../review_apps/index.html)部署更改,以預覽每個分支上的應用程序更改. 2. **Package**: * 使用[Container Registry](../../user/packages/container_registry/index.html)存儲 Docker 映像. * 使用[NPM Registry](../../user/packages/npm_registry/index.html)存儲 NPM 軟件包. * 用[Maven 存儲庫](../../user/packages/maven_repository/index.html)存儲 Maven 工件. * 將 Conan 軟件包存儲在[Conan 倉庫中](../../user/packages/conan_repository/index.html) . 3. **Release**: * 持續部署,自動將您的應用程序部署到生產環境. * 連續交付,手動單擊以將您的應用程序部署到生產環境. * 使用[GitLab Pages](../../user/project/pages/index.html)部署靜態網站. * 僅將功能部件運送到您的一部分吊艙中,并讓一定比例的用戶群通過[Canary Deployments](../../user/project/canary_deployments.html)訪問臨時部署的功能部件. * 在[功能標記](../../operations/feature_flags.html)后面部署[功能](../../operations/feature_flags.html) . * 使用[GitLab Releases](../../user/project/releases/index.html)向任何 Git 標簽添加發行說明. * View of the current health and status of each CI environment running on Kubernetes with [Deploy Boards](../../user/project/deploy_boards.html). * 使用[Auto Deploy](../../topics/autodevops/stages.html#auto-deploy)將應用程序部署到 Kubernetes 集群中的生產環境. 使用 GitLab CI / CD,您還可以: * 通過[Auto DevOps](../../topics/autodevops/index.html)輕松設置應用程序的整個生命周期. * 將您的應用程序部署到不同的[環境](../environments/index.html) . * 安裝自己的[GitLab Runner](https://docs.gitlab.com/runner/) . * [Schedule pipelines](../pipelines/schedules.html). * 使用[安全測試報告](../../user/application_security/index.html)檢查應用程序漏洞. 要查看所有 CI / CD 功能,請導航回[CI / CD 索引](../README.html) . 觀看視頻[GitLab CI Live 演示](https://youtu.be/l5705U8s_nQ?t=369) ,深入了解 GitLab CI / CD. ### Setting up GitLab CI/CD for the first time[](#setting-up-gitlab-cicd-for-the-first-time "Permalink") 要開始使用 GitLab CI / CD,您需要熟悉[`.gitlab-ci.yml`](../yaml/README.html)配置文件的語法及其屬性. 本文檔[在 GitLab Pages 的范圍內介紹了 GitLab CI / CD 的概念](../../user/project/pages/getting_started/pages_from_scratch.html) ,用于部署靜態網站. 盡管它是為想要從頭開始編寫自己的 Pages 腳本的用戶而設計的,但它也可以作為 GitLab CI / CD 設置過程的簡介. 它涵蓋了編寫 CI / CD 配置文件的最初一般步驟,因此我們建議您通讀它以了解 GitLab 的 CI / CD 邏輯,并學習如何為任何應用程序編寫自己的腳本(或調整現有腳本). 要深入了解 GitLab 的 CI / CD 配置選項,請查看[`.gitlab-ci.yml`完整參考](../yaml/README.html) .
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看