Pipeline
Pipeline
An automated workflow. CI/CD pipelines are the best-known example. Connects build, test, and deployment stages.
Pipeline
An automated workflow. CI/CD pipelines are the best-known example. Connects build, test, and deployment stages.
A pipeline is an automated workflow in software development. A CI/CD pipeline is a representative example, automatically connecting the build, test, and deployment stages from code commit to production deployment.
A pipeline consists of sequential stages and parallel jobs. Each stage runs after the previous stage succeeds, and the jobs within a stage can run in parallel. If a failure occurs, the entire pipeline is halted, providing fast feedback.
Major tools include Jenkins, GitHub Actions, GitLab CI, CircleCI, and Azure Pipelines. Pipelines are defined in YAML or a DSL and version-controlled in a Git repository. Sensitive information is passed securely through environment variables and secrets.
In practice, a testing pipeline is run for every PR, and a deployment pipeline is triggered when merging into the main branch. Automatic deployment to staging and a manual approval gate for production are configured. Caching and parallelization keep the pipeline time within 10 minutes.
# GitHub Actions CI/CD Pipeline
name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# 1. 테스트 스테이지
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run tests
run: npm run test:ci
- name: Upload coverage
uses: codecov/codecov-action@v3
# 2. 빌드 스테이지
build:
needs: test
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.meta.outputs.tags }}
steps:
- uses: actions/checkout@v4
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
# 3. 배포 스테이지 (Staging)
deploy-staging:
needs: build
runs-on: ubuntu-latest
environment: staging
steps:
- name: Deploy to Staging
run: |
kubectl set image deployment/web \
web=${{ needs.build.outputs.image_tag }}
# 4. 배포 스테이지 (Production - 수동 승인)
deploy-production:
needs: [build, deploy-staging]
runs-on: ubuntu-latest
environment: production # 승인 필요
if: github.ref == 'refs/heads/main'
steps:
- name: Deploy to Production
run: |
kubectl set image deployment/web \
web=${{ needs.build.outputs.image_tag }}
Senior: "The pipeline takes as long as 20 minutes. It looks like it needs optimization."
Junior: "If we split the tests to run in parallel and add caching, I think we can bring it down to around 10 minutes."
Interviewer: "What should be considered when designing a CI/CD pipeline?"
Candidate: "For speed, I apply caching and parallelization, and for fast feedback, I place the tests at the front. For security, I apply secrets management and the principle of least privilege, and I set up an approval gate for production deployment."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
Reviewer: "Using the secrets context is safer than passing secrets directly as environment variables."
Developer: "Yes, I'll change it to the ${{ secrets.API_KEY }} form instead of env."