<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國際加速解決方案。 廣告
                # Getting started with GitLab CI/CD > 原文:[https://docs.gitlab.com/ee/ci/quick_start/README.html](https://docs.gitlab.com/ee/ci/quick_start/README.html) * [Creating a `.gitlab-ci.yml` file](#creating-a-gitlab-ciyml-file) * [What is `.gitlab-ci.yml`](#what-is-gitlab-ciyml) * [Creating a simple `.gitlab-ci.yml` file](#creating-a-simple-gitlab-ciyml-file) * [Push `.gitlab-ci.yml` to GitLab](#push-gitlab-ciyml-to-gitlab) * [Configuring a Runner](#configuring-a-runner) * [Shared Runners](#shared-runners) * [Seeing the status of your pipeline and jobs](#seeing-the-status-of-your-pipeline-and-jobs) * [Examples](#examples) # Getting started with GitLab CI/CD[](#getting-started-with-gitlab-cicd "Permalink") **注意:**從 8.0 版開始,GitLab [持續集成](https://about.gitlab.com/stages-devops-lifecycle/continuous-integration/) (CI)已完全集成到 GitLab 本身,并且默認情況下在所有項目上都[啟用](../enable_or_disable_ci.html) .**注意:**請記住,只有項目維護者和管理員用戶有權訪問項目的設置.**注意:**要從 Jenkins 轉到 GitLab 嗎? 查閱我們的[參考](../jenkins/index.html) ,將您先前存在的管道轉換為我們的格式.**注意:**您可以考慮在項目中使用幾種不同的[基本管道體系結構](../pipelines/pipeline_architectures.html) . 您可能需要在開始之前熟悉這些內容. GitLab 提供[持續集成](https://about.gitlab.com/stages-devops-lifecycle/continuous-integration/)服務. 對于每次提交或推送以觸發您的 CI [管道](../pipelines/index.html) ,您必須: * Add a [`.gitlab-ci.yml` file](#creating-a-gitlab-ciyml-file) to your repository’s root directory. * 確保將項目配置為使用[Runner](#configuring-a-runner) . `.gitlab-ci.yml`文件告訴 GitLab Runner 做什么. 一個簡單的管道通常包括三個[階段](../yaml/README.html#stages) : * `build` * `test` * `deploy` 您不需要使用所有三個階段; 沒有工作的階段將被忽略. 管道顯示在項目的**CI / CD>管道**頁面下. 如果一切運行正常(沒有非零返回值),您將獲得與提交關聯的綠色復選標記. 這樣就可以輕松查看提交是否導致任何測試失敗,甚至無需查看作業(測試)日志. 許多項目使用 GitLab 的 CI 服務來運行測試套件,因此如果開發人員遇到問題,他們會立即獲得反饋. 通常,使用管道將經過測試的代碼自動部署到登臺和生產環境中. * * * 本指南假定您具有: * 8.0+或正在使用[GitLab.com 的](https://gitlab.com)有效 GitLab 實例. * 您要在其中使用 CI 的 GitLab 中的項目. * 維護者或所有者對項目的訪問 讓我們將其分解為 GitLab CI / CD 難題. ## Creating a `.gitlab-ci.yml` file[](#creating-a-gitlab-ciyml-file "Permalink") 在創建`.gitlab-ci.yml`之前,讓我們首先簡要地解釋這是怎么回事. ### What is `.gitlab-ci.yml`[](#what-is-gitlab-ciyml "Permalink") 您可以在`.gitlab-ci.yml`文件中配置 CI 對項目的作用. 它位于存儲庫的根目錄中. 在對存儲庫進行任何推送時,GitLab 都會查找`.gitlab-ci.yml`文件,并根據該文件的內容在*Runners*上啟動作業,以進行提交. 由于`.gitlab-ci.yml`在存儲庫中并且受版本控制,因此舊版本仍然可以成功構建,fork 可以輕松使用 CI,分支可以具有不同的管道和作業,并且您擁有 CI 的唯一真實來源. 您可以[在我們的博客中](https://about.gitlab.com/blog/2015/05/06/why-were-replacing-gitlab-ci-jobs-with-gitlab-ci-dot-yml/)閱讀更多有關為什么使用`.gitlab-ci.yml`的原因. ### Creating a simple `.gitlab-ci.yml` file[](#creating-a-simple-gitlab-ciyml-file "Permalink") > **注意:** `.gitlab-ci.yml`是一個[YAML](https://en.wikipedia.org/wiki/YAML)文件,因此您必須特別注意縮進. 始終使用空格,不要使用制表符. 您需要在存儲庫的根目錄中創建一個名為`.gitlab-ci.yml`的文件. 以下是 Ruby on Rails 項目的示例. ``` image: "ruby:2.5" before_script: - apt-get update -qq && apt-get install -y -qq sqlite3 libsqlite3-dev nodejs - ruby -v - which ruby - gem install bundler --no-document - bundle install --jobs $(nproc) "${FLAGS[@]}" rspec: script: - bundle exec rspec rubocop: script: - bundle exec rubocop ``` This is the simplest possible configuration that will work for most Ruby applications: 1. 用要執行的不同命令定義兩個作業`rspec`和`rubocop` (名稱是任意的). 2. 在執行每個作業之前,將執行`before_script`定義的命令. `.gitlab-ci.yml`文件定義了作業集,并限制了作業的運行方式和時間. 作業被定義為具有名稱的頂級元素(在我們的示例中為`rspec`和`rubocop` ),并且始終必須包含`script`關鍵字. 喬布斯被用于創造就業機會,然后由挑選[運動員](../runners/README.html)和跑步者的環境中執行. 重要的是每個作業都彼此獨立運行. 如果要檢查項目的`.gitlab-ci.yml`是否有效,則項目名稱空間的`/-/ci/lint`頁下有一個 Lint 工具. 您也可以在項目的**CI / CD?管道**和**管道?作業**下找到" CI Lint"按鈕以轉到此頁面. 有關更多信息和完整的`.gitlab-ci.yml`語法,請閱讀[`.gitlab-ci.yml`上的參考文檔](../yaml/README.html) . ### Push `.gitlab-ci.yml` to GitLab[](#push-gitlab-ciyml-to-gitlab "Permalink") 創建`.gitlab-ci.yml` ,應將其添加到 Git 存儲庫中并將其推送到 GitLab. ``` git add .gitlab-ci.yml git commit -m "Add .gitlab-ci.yml" git push origin master ``` 現在,如果您轉到" **管道"**頁面,您將看到管道處于掛起狀態. **注意:**如果您有一個[從 GitLab 提取鏡像的存儲庫](../../user/project/repository/repository_mirroring.html#pulling-from-a-remote-repository-starter) ,則可能需要在項目的**"設置">"存儲庫">"從遠程存儲庫中提取">"觸發管道以進行鏡像更新"中**啟用管道觸發. 您也可以轉到" **提交"**頁面,注意提交 SHA 旁邊的小暫停圖標. [![New commit pending](https://img.kancloud.cn/d6/d8/d6d8f9854e951bf6a9170fc7dff494bd_764x102.png)](img/new_commit.png) 單擊它,您將被定向到該特定提交的作業頁面. [![Single commit jobs page](https://img.kancloud.cn/81/c6/81c60ef1cf638b798cfcbb40d03b4b1b_1264x386.png)](img/single_commit_status_pending.png) 注意,有一個待處理的作業以我們在`.gitlab-ci.yml`編寫的`.gitlab-ci.yml` . "卡住"表示尚未為此作業配置任何運行器. 下一步是配置運行器,以便它選擇掛起的作業. ## Configuring a Runner[](#configuring-a-runner "Permalink") 在 GitLab 中,Runners 運行您在`.gitlab-ci.yml`定義的作業. Runner 可以是虛擬機,VPS,裸機,Docker 容器甚至是容器集群. GitLab 和 Runners 通過 API 進行通信,因此唯一的要求是 Runner 的計算機具有對 GitLab 服務器的網絡訪問權限. Runner 可以特定于某個項目,也可以在 GitLab 中服務多個項目. 如果它服務于所有項目,則稱為*Shared Runner* . 在" [跑步者"](../runners/README.html)文檔中查找有關不同跑步者的更多信息. 您可以通過轉到**設置?CI / CD**來查找是否將任何跑步者分配給您的項目. 設置 Runner 既簡單又直接. GitLab 支持的官方 Runner 是用 Go 編寫的,其文檔可以在[https://docs.gitlab.com/runner/中](https://docs.gitlab.com/runner/)找到. 為了擁有功能正常的 Runner,您需要執行以下兩個步驟: 1. [Install it](https://docs.gitlab.com/runner/install/) 2. [Configure it](https://docs.gitlab.com/runner/configuration/) 請按照上面的鏈接設置您自己的 Runner 或使用下一節所述的 Shared Runner. 設置 Runner 之后,您應該在**設置?CI / CD**后面的項目的 Runners 頁面上看到它. [![Activated runners](https://img.kancloud.cn/ab/93/ab93d24f99dee31b671345213865f2d0_1728x1240.png)](img/runners_activated.png) ### Shared Runners[](#shared-runners "Permalink") 如果使用[GitLab.com](https://gitlab.com/) ,則可以使用 GitLab Inc.提供的**共享運行程序** . 這些是在 GitLab 基礎架構上運行的特殊虛擬機,可以構建任何項目. 要啟用**共享運行程序,**您必須轉到項目的**設置?CI / CD** ,然后單擊**啟用共享運行程序** . [Read more on Shared Runners](../runners/README.html). ## Seeing the status of your pipeline and jobs[](#seeing-the-status-of-your-pipeline-and-jobs "Permalink") 成功配置 Runner 之后,您應該看到上一次提交的狀態從" *未決"*更改為" *正在* *運行"* ," *成功"*或" *失敗"* . 您可以轉到項目中的" **管道"**頁面來查看所有管道. [![Commit status](https://img.kancloud.cn/d1/95/d195986d01878d87d8b88b93c928e8d5_2296x734.png)](img/pipelines_status.png) 或者,您可以轉到" **管道?作業"**頁面查看所有作業. [![Commit status](https://img.kancloud.cn/b2/fa/b2fa43919cc79cc75d5fa469818ecea0_2300x547.png)](img/builds_status.png) 通過單擊作業的狀態,您將能夠看到該作業的日志. 這對于診斷工作為什么失敗或行為與您預期的不同很重要. [![Build log](https://img.kancloud.cn/fb/ee/fbeef7fa796067bf2c3e5f9ad3dddf74_2458x1350.png)](img/build_log.png) 您還可以在 GitLab 的各個頁面中查看任何提交的狀態,例如**提交**和**合并請求** . ## Examples[](#examples "Permalink") 請訪問[示例自述文件](../examples/README.html)以查看使用各種語言的 GitLab CI 的示例列表.
                  <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>

                              哎呀哎呀视频在线观看