ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • CI/CD 구축에 필요한 YAML
    개발 관련/CI&CD 2020. 9. 26. 00:23

    YAML (YAML Ain't Markup Language)

    사전적 의미: 모든 프로그래밍 언어를 위한 인간 친화적 데이터 직렬화(Serialization) 표준
    CI/CD 파이프라인 빌드 구성(configuration)을 정의
    Repository 루트에 존재

    파이프 라인은 단계 리스트로 구성

    default

    브랜치 섹션에서 정의된 브랜치를 제외한 repository에 대한 모든 푸시에 실행 (+tags/bookmarks에 실행 X)

    branches

    모든 브랜치별 빌드 파이프 라인에 대한 섹션 정의 (names, expressions)

    tags

    모든 태그별 빌드 파이프 라인 정의 (names, expressions)

    bookmarks

    모든 북마크별 빌드 파이프 라인 정의 (names, expressions)

    pull requests

    repository에 대한 pull requests가 행해졌을 때 실행되는 특별한 파이프라인 정의

    custom 

    수동으로 트리거할 수 있는 또는 스케쥴된 파이프라인 정의

     

    Example:

    더보기
    image: node:10.15.0
       
    pipelines:
      default:
        - step:
            name: Build and test
            script:
              - npm install
              - npm test
      tags:                         # add the 'tags' section
        release-*:                  # specify the tag
          - step:                   # define the build pipeline for the tag
              name: Build and release
              script:
                - npm install
                - npm test
                - npm run release
      pull-requests:
        '**': #this runs as default for any branch not elsewhere defined
          - step:
              script:
                - ...
        feature/*: #any branch with a feature prefix
          - step:
              script:
                - ...
      bookmarks:                      # add the 'bookmarks' section
        release-*:                    # specify the bookmark
          - step:                     # define the build pipeline for the bookmark
              name: Build and release
              script:
                - npm install
                - npm test
                - npm run release
      custom: # Pipelines that are triggered manually
        sonar: # The name that is displayed in the list in the Bitbucket Cloud GUI
          - step:
              script:
                - echo "Manual triggers for Sonar are awesome!"
        deployment-to-prod: # Another display name
          - step:
              script:
                - echo "Manual triggers for deployments are awesome!"
      branches:
        staging:
          - step:
              name: Clone
              script:
                - echo "Clone all the things!"

    variable 

    커스텀 파이프라인에서 사용되며, 파이프라인이 시작될 때 제공되는 변수 정의

    step

    빌드 실행 유닛 정의, 순서대로 실행됨, 각 step마다 스크립트에 구성된 명령문(commands)을 실행하기 위해 독립된 Docker 컨테이너를 시작함 (1 스텝 1 Docker 컨테이너)

    image

    Docker 컨테이너를 사용하여 빌드 실행 (=public 또는 private Docker 이미지)

    trigger

    step이 자동으로 또는 수동적 트리거로 인해 실행될지 명시

    deployment

    배포 단계에 대한 환경 타입을 설정 (test, staging, production)

    script

    순서대로 실행되는 명령문(commands) 리스트, step에 명시된 순서로 실행됨

    artifacts

    step에 의해 생성된 파일을 다음 step에 공유하기위해 정의

    max-time

    step 실행 최대 시간(분 단위), 0 -120 사이 지정

    clone

    repository를 컨테이너로 복제(clone)할 때를 대한 설정(settings) 정의

    definitions

    파이프라인 구성(configuration)에서 사용되는 리소스 정의

    services

    파이프라인은 서비스를 위한 별도의 Docker 컨테이너 가동할 수 있음 → 빠른 빌드, 쉬운 서비스 수정
    caches

    캐시를 사용하여, 서버로 한 번 다운로드된 다음 매번 빌드에 로컬로 로드됨 (각 빌드 step의 dependencies를 매번 다운로드하는 것은 많은 시간 소요)

     

    '개발 관련 > CI&CD' 카테고리의 다른 글

    CI / CD / CD  (0) 2021.02.11
    CICD 파이프라인 시나리오  (0) 2021.02.11
Designed by Tistory.