DevOps

2023.04.30 - [DevOps] - CircleCi Yaml Configure 살펴보기 2. sample config.yml

r잡초처럼 2023. 5. 1. 22:22

2023.04.30 - [DevOps] - CircleCi Yaml Configure 살펴보기 1 - Jobs

 

CircleCi Yaml Configure 살펴보기 1 - Jobs

공식 문서 튜토리얼을 공부했다. 1. Jobs # CircleCI configuration file version: 2.1 jobs: build: docker: # Primary container image where all steps run - image: cimg/base:2022.05 auth: username: mydockerhub-user password: $DOCKERHUB_PASSWORD # co

barun-programing.tistory.com

어제에 이어서 공식 문서 예제를 보고 config.yml을 이해해보자

Simple configuration examples

Concurrent workflow

  • 아래 구성 예제는 빌드 및 테스트 작업이 동시에 실행되는 병렬 워크플로를 보여준다.
  • 두 작업 모두 CircleCI에서 제공하는 기본 이미지를 사용하여 Docker 컨테이너에서 실행한다. 

version: 2.1

# Define the jobs we want to run for this project
jobs:
  build:
    docker:
      - image: cimg/base:2023.03
    steps:
      - checkout
      - run: echo "this is the build job"
  test:
    docker:
      - image: cimg/base:2023.03
    steps:
      - checkout
      - run: echo "this is the test job"

# Orchestrate our job run sequence
workflows:
  build_and_test:
    jobs:
      - build
      - test

Sequential workflow

  • 아래 구성 예제는 빌드 작업이 실행되고, 빌드가 완료된 후 테스트 작업이 실행되는 순차적인 워크플로우를 보여준다.
  • 이를 위해 requires 키를 사용하여 테스트 작업이 실행되기 위해서는 빌드 작업이 필요하다고 지정한다.
  • 두 작업 모두 CircleCI에서 제공하는 기본 이미지를 사용하여 Docker 컨테이너에서 실행된다. 
version: 2.1

# Define the jobs we want to run for this project
jobs:
  build:
    docker:
      - image: cimg/base:2023.03
    steps:
      - checkout
      - run: echo "this is the build job"
  test:
    docker:
      - image: cimg/base:2023.03
    steps:
      - checkout
      - run: echo "this is the test job"

# Orchestrate our job run sequence
workflows:
  build_and_test:
    jobs:
      - build
      - test:
          requires:
            - build

Approval job

  • 아래 예제는 승인 단계가 있는 순차적인 워크플로우를 보여준다.
  • 빌드 작업이 실행되고, 그 다음에 테스트 작업이 실행되고, 그 후에 CircleCI에서 제공하는 기본 이미지를 사용하여 Docker 컨테이너에서 실행되는 hold 작업이 실행된다.
  • 이때 type: approval을 사용하여 워크플로우가 CircleCI 웹 앱에서 수동 승인을 받아야만 배포 작업이 실행될 수 있도록 한다. 
version: 2.1

# Define the jobs we want to run for this project
jobs:
  build:
    docker:
      - image: cimg/base:2023.03
    steps:
      - checkout
      - run: echo "this is the build job"
  test:
    docker:
      - image: cimg/base:2023.03
    steps:
      - checkout
      - run: echo "this is the test job"
  deploy:
    docker:
      - image: cimg/base:2023.03
    steps:
      - checkout
      - run: echo "this is the deploy job"

# Orchestrate our job run sequence
workflows:
  build_and_test:
    jobs:
      - build
      - test:
          requires:
            - build
      - hold:
          type: approval
          requires:
            - build
            - test
      - deploy:
          requires:
            - hold