<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # GitLab CI/CD include examples > 原文:[https://docs.gitlab.com/ee/ci/yaml/includes.html](https://docs.gitlab.com/ee/ci/yaml/includes.html) * [Single string or array of multiple values](#single-string-or-array-of-multiple-values) * [Re-using a `before_script` template](#re-using-a-before_script-template) * [Overriding external template values](#overriding-external-template-values) * [Using nested includes](#using-nested-includes) # GitLab CI/CD include examples[](#gitlab-cicd-include-examples "Permalink") 除了[GitLab CI YAML 參考中](README.html)列出的[`includes`示例](README.html#include)之外,此頁面還列出了`include`用法的更多變化. ## Single string or array of multiple values[](#single-string-or-array-of-multiple-values "Permalink") 您可以將額外的 YAML 文件作為單個字符串或多個值的數組包含在內. 以下示例均有效. `include:local`方法的單個字符串暗含: ``` include: '/templates/.after-script-template.yml' ``` Array with `include` method implied: ``` include: - 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml' - '/templates/.after-script-template.yml' ``` 具有明確指定的`include`方法的單個字符串: ``` include: remote: 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml' ``` `include:remote`為單個項目的數組: ``` include: - remote: 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml' ``` 具有多個顯式指定的`include`方法的數組: ``` include: - remote: 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml' - local: '/templates/.after-script-template.yml' - template: Auto-DevOps.gitlab-ci.yml ``` 數組混合語法: ``` include: - 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml' - '/templates/.after-script-template.yml' - template: Auto-DevOps.gitlab-ci.yml - project: 'my-group/my-project' ref: master file: '/templates/.gitlab-ci-template.yml' ``` ## Re-using a `before_script` template[](#re-using-a-before_script-template "Permalink") 在以下示例中, `.before-script-template.yml`的內容將與`.gitlab-ci.yml`的內容一起自動獲取和評估. `https://gitlab.com/awesome-project/raw/master/.before-script-template.yml`內容: ``` before_script: - apt-get update -qq && apt-get install -y -qq sqlite3 libsqlite3-dev nodejs - gem install bundler --no-document - bundle install --jobs $(nproc) "${FLAGS[@]}" ``` `.gitlab-ci.yml`內容: ``` include: 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml' rspec: script: - bundle exec rspec ``` ## Overriding external template values[](#overriding-external-template-values "Permalink") 以下示例顯示了特定的 YAML 定義的變量以及`.gitlab-ci.yml`自定義的包含文件中`production`作業的詳細信息. `https://company.com/autodevops-template.yml`內容: ``` variables: POSTGRES_USER: user POSTGRES_PASSWORD: testing_password POSTGRES_DB: $CI_ENVIRONMENT_SLUG production: stage: production script: - install_dependencies - deploy environment: name: production url: https://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN only: - master ``` `.gitlab-ci.yml`內容: ``` include: 'https://company.com/autodevops-template.yml' image: alpine:latest variables: POSTGRES_USER: root POSTGRES_PASSWORD: secure_password stages: - build - test - production production: environment: url: https://domain.com ``` 在這種情況下,變量`POSTGRES_USER`和`POSTGRES_PASSWORD`以及`autodevops-template.yml`定義的`production`作業的環境 URL 已被`.gitlab-ci.yml`定義的新值覆蓋. 合并使您可以擴展和覆蓋字典映射,但是不能向包含的數組添加或修改項目. 例如,要將其他項目添加到生產作業腳本中,必須重復現有的腳本項目: `https://company.com/autodevops-template.yml`內容: ``` production: stage: production script: - install_dependencies - deploy ``` `.gitlab-ci.yml`內容: ``` include: 'https://company.com/autodevops-template.yml' stages: - production production: script: - install_dependencies - deploy - notify_owner ``` 在這種情況下,如果未在`.gitlab-ci.yml`重復`install_dependencies`和`deploy` ,則它們將不會成為組合 CI 配置中`production`作業腳本的一部分. ## Using nested includes[](#using-nested-includes "Permalink") 以下示例顯示了如何使用不同方法的組合從不同來源嵌套包含對象. 在此示例中, `.gitlab-ci.yml`本地包含文件`/.gitlab-ci/another-config.yml` : ``` include: - local: /.gitlab-ci/another-config.yml ``` `/.gitlab-ci/another-config.yml`包含一個模板和另一個項目中的`/templates/docker-workflow.yml`文件: ``` include: - template: Bash.gitlab-ci.yml - project: group/my-project file: /templates/docker-workflow.yml ``` 該`/templates/docker-workflow.yml`出現在`group/my-project`包括的兩個本地文件`group/my-project` : ``` include: - local: /templates/docker-build.yml - local: /templates/docker-testing.yml ``` 我們在`group/my-project` `/templates/docker-build.yml`添加了一個`docker-build`作業: ``` docker-build: script: docker build -t my-image . ``` 我們在`group/my-project`出現的第二個`/templates/docker-test.yml`添加了一個`docker-test`作業: ``` docker-test: script: docker run my-image /run/tests.sh ```
                  <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>

                              哎呀哎呀视频在线观看