This page contains information related to upcoming products, features, and functionality. It is important to note that the information presented is for informational purposes only. Please do not rely on this information for purchasing or planning purposes. As with all projects, the items mentioned on this page are subject to change or delay. The development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.
Status Authors Coach DRIs Owning Stage Created
proposed devops verify -

GitLab Steps.gitlab-ci.yml 사용

이 문서는 GitLab Steps.gitlab-ci.yml에 통합되는 방법을 설명합니다.

GitLab Steps은 세 단계의 실행 주기를 사용하여 통합되며 before_script:, script:, after_script:을 대체합니다.

  • setup:: 리포지토리 클론, 아티팩트 복원 또는 모든 종속성 설치와 같이 환경을 프로비저닝하는 실행 단계를 담당합니다. 이 단계는 암시적으로 클론, 아티팩트 복원 및 캐시 다운로드를 대체합니다.
  • run:: 테스트 실행, 빌드 또는 해당 작업에서 필요한 기본 명령을 실행하는 실행 단계를 담당합니다.
  • teardown:: 환경을 정리하거나 아티팩트를 업로드하거나 캐시를 저장하는 실행 단계를 담당합니다. 이 단계는 암시적으로 아티팩트 및 캐시 업로드를 대체합니다.

우리가 3단계 실행을 달성하기 전에, 사전 GitLab 통합이 필요하지 않은 최소한의 초기 지원을 제공할 것입니다.

단계 1: 초기 지원

초기에는 Step Runner가 사전 종속성 없이 외부적으로 사용될 것입니다:

  • step-runner은 컨테이너 이미지의 일부로 제공될 것입니다.
  • step-runnerscript: 섹션에서 명시적으로 실행될 것입니다.
  • $STEPS 환경 변수가 type: steps으로 실행될 것입니다.
hello-world:
  image: registry.gitlab.com/gitlab-org/step-runner
  variables:
    STEPS: |
      - step: gitlab.com/josephburnett/component-hello-steppy@master
        inputs:
          greeting: "hello world"
  script:
    - /step-runner ci

단계 2: .gitlab-ci.ymlrun: 추가

2단계에서 run:이 GitLab Steps를 사용하는 첫 번째 방법으로 추가될 것입니다:

  • run:type: steps 구문을 사용할 것입니다.
  • run:before_script, scriptafter_script의 사용을 대체할 것입니다.
  • Git 클론, 아티팩트 및 캐시를 지원하기 위한 모든 기존 기능은 계속 지원될 것입니다.
  • 취소된 작업 상태이거나 무조건적으로 실행되는 after_script를 어떻게 지원할지 아직 정의되지 않았습니다.
  • run:before_script:, script:, after_script:과 함께 사용할 수 없습니다.
  • GitLab Rails는 run:을 구문 검증 JSON 스키마로만 수행하며 구문을 분석하지는 않을 것입니다.
hello-world:
  image: registry.gitlab.com/gitlab-org/step-runner
  run:
    - step: gitlab.com/josephburnett/component-hello-steppy@master
      inputs:
        greeting: "hello world"

다음 예제는 구문 검증이 실패합니다:

hello-world:
  image: registry.gitlab.com/gitlab-org/step-runner
  run:
    - step: gitlab.com/josephburnett/component-hello-steppy@master
      inputs:
        greeting: "hello world"
  script: echo "모호하고 잘못된 예제입니다"

before_script:, script:, 및 after_script:에서의 전환

GitLab Rails는 *script: 구문을 관련 run: 사양으로 자동으로 변환할 것입니다:

  • 오늘날, before_script:script:은 실행을 위해 단일 스크립트로 결합됩니다.
  • after_script: 섹션은 항상 별도의 컨텍스트에서 실행되며 실행할 별도의 단계를 나타냅니다.
  • 작업 상태나 타임아웃 관계 없이 항상 실행되는 after_script의 기존 동작을 어떻게 유지할지 아직 정의되지 않았습니다.
  • script:을 기반으로 환경 변수를 정의하는 모든 암시적 동작은 유지될 것입니다.

예를 들어, 이 CI/CD 구성:

hello-world:
  before_script:
    - echo "Run before_script"
  script:
    - echo "Run script"
  after_script:
    - echo "Run after_script"

다음과 같은 동등한 사양으로 변환될 수 있습니다:

hello-world:
  run:
    - step: gitlab.com/gitlab-org/components/steps/legacy/script@v1.0
      inputs:
        script:
          - echo "Run before_script"
          - echo "Run script"
    - step: gitlab.com/gitlab-org/components/steps/legacy/script@v1.0
      inputs:
        script:
          - echo "Run after_script"
      when: always

단계 3: .gitlab-ci.ymlsetup:teardown: 추가

setup:teardown:을 추가함으로써 GitLab Runner가 암시적으로 제공하는 기능을 대체할 것입니다: Git 클론, 아티팩트 및 캐시 처리입니다:

  • setup:의 사용은 GitLab Runner가 리포지토리를 암시적으로 클론하는 것을 중지시킬 것입니다.
  • artifacts:cache:는 지정되었을 때 이전 구문의 하위 호환성을 제공하도록 setup:teardown:에 변환되고 추가될 것입니다.
  • release:는 지정되었을 때, 이전 구문의 하위 호환성을 제공하기 위해 teardown:에 변환되고 추가될 것입니다.
  • setup:teardown:은 리포지토리가 클론되거나 아티팩트가 처리되는 공통 워크플로우의 지원을 단순화하는 default:에서 사용될 수 있을 것입니다.
  • extends:와 함께 hooks:pre_get_sources_scriptsetup:에 선행되도록 구현될 것입니다.

예를 들어, 이 CI/CD 구성:

rspec:
  script:
    - echo "This job uses a cache."
  artifacts:
    paths: [binaries/, .config]
  cache:
    key: binaries-cache
    paths: [binaries/*.apk, .config]

다음과 같은 동등한 사양으로 변환될 수 있습니다:

rspec:
  setup:
    - step: gitlab.com/gitlab-org/components/git/clone@v1.0
    - step: gitlab.com/gitlab-org/components/artifacts/download@v1.0
    - step: gitlab.com/gitlab-org/components/cache/restore@v1.0
      inputs:
        key: binaries-cache
  run:
    - step: gitlab.com/gitlab-org/components/steps/legacy/script@v1.0
      inputs:
        script:
          - echo "This job uses a cache."
  teardown:
    - step: gitlab.com/gitlab-org/components/artifacts/upload@v1.0
      inputs:
        paths: [binaries/, .config]
    - step: gitlab.com/gitlab-org/components/cache/restore@v1.0
      inputs:
        key: binaries-cache
        paths: [binaries/*.apk, .config]

default:으로 공통 작업 상속하기

시간이 지남에 따라 setup:teardown:은 매우 상세해질 수 있습니다. 이를 간소화하는 한 가지 방법은 default:를 사용하여 공통 setup:teardown: 작업을 상속하는 것입니다.

이전 예제는 다음과 같이 간소화될 수 있습니다:

default:
  setup:
    - step: gitlab.com/gitlab-org/components/git/clone@v1.0
    - step: gitlab.com/gitlab-org/components/artifacts/download@v1.0
    - step: gitlab.com/gitlab-org/components/cache/restore@v1.0
      inputs:
        key: binaries-cache
  teardown:
    - step: gitlab.com/gitlab-org/components/artifacts/upload@v1.0
      inputs:
        paths: [binaries/, .config]
    - step: gitlab.com/gitlab-org/components/cache/restore@v1.0
      inputs:
        key: binaries-cache
        paths: [binaries/*.apk, .config]

rspec:
  run:
    - step: gitlab.com/gitlab-org/components/steps/legacy/script@v1.0
      inputs:
        script:
          - echo "This job uses a cache."

linter:
  run:
    - step: gitlab.com/gitlab-org/components/steps/legacy/script@v1.0
      inputs:
        script:
          - echo "Run linting"

병렬 작업 및 setup:

setup:의 도입으로 우리는 향후 작업을 병렬화하는 효율적인 방법을 도입할 것입니다.

  • setup:은 환경을 프로비저닝하는 데 필요한 모든 단계를 정의할 것입니다.
  • setup:의 결과는 parallel: N이 사용된 경우 모든 병렬 작업의 기본으로 스냅샷으로 만들어져 분산될 것입니다.
  • run:teardown:은 복제된 작업 및 해당 서비스 위에서 실행될 것입니다.
  • 러너는 모든 병렬 작업을 제어하고 지능적으로 분배하여 작업의 고정 부분( Git clone, artifacts, 종속성 설치)에 대한 리소스 요구를 크게 줄일 것입니다.
rspec-parallel:
  image: ruby:3.2
  services: [postgres, redis]
  parallel: 10
  setup:
    - step: gitlab.com/gitlab-org/components/git/clone@v1.0
    - step: gitlab.com/gitlab-org/components/artifacts/download@v1.0
      inputs:
        jobs: [setup-all]
    - script: bundle install --without production
  run:
    - script: bundle exec knapsack

잠재적인 GitLab 러너 흐름:

  1. 러너는 setup:parallel:이 구성된 rspec-parallel 작업을 수신합니다.
  2. 러너는 블록 볼륨을 사용하여 Kubernetes 클러스터 상단에 작업을 실행합니다.
  3. 러너는 Kubernetes에서 10개의 병렬 작업을 실행하고, 2번의 블록 볼륨을 오버레이하고 run:teardown: 실행을 계속합니다.