QA Automation Pipeline

SW Development
GitHub에 push하면 테스트가 자동으로 돌고, 통과해야만 배포된다 — 사람이 테스트 실행을 기억할 필요가 없다
Posted on June 26, 2026, 11:15 a.m. by SANGJIN
random_image

Built a CI/CD pipeline that enforces test-before-deploy: a GitHub push triggers Jenkins via webhook, Pytest runs automatically, and deployment only proceeds if all tests pass. If tests fail, the pipeline stops at the test stage — deploy never runs.

Jenkins itself runs inside Docker (docker compose up), so the entire environment — Jenkins server, app container, and pipeline config — is defined as code.

Key decisions:

Decision Rationale
Jenkins in Docker Environment as code. docker compose up brings up Jenkins + app in one command
Pytest inside python:3.11-alpine No Python installation needed on the Jenkins host
reuseNode true Shares the venv across stages without rebuilding it each time
disableConcurrentBuilds() Prevents workspace @2 collision that breaks venv paths
post { always { junit } } Test reports are generated even on failure — debugging requires failure data
docker.sock mount Lets Jenkins container call docker compose on the host Docker daemon

Pipeline stages:

Stage Environment Role
Checkout Host (docker-node) Pull code from GitHub
Set Up Python Env python:3.11-alpine Create venv + install dependencies
Run Pytest python:3.11-alpine Run tests + generate JUnit XML
Deploy Host (docker-node) docker compose up --build
JUnit Report Host (docker-node) Publish test results to Jenkins UI

Tech: Python, Pytest, Jenkins, Docker, docker-compose, GitHub Webhook, JUnit


GitHub push → Jenkins Webhook 트리거 → Pytest 자동 실행 → 통과 시에만 배포되는 CI/CD 파이프라인을 구축했다. 테스트가 실패하면 파이프라인이 그 자리에서 멈춘다. 배포 스테이지는 실행되지 않는다.

Jenkins 자체도 Docker로 띄운다. docker compose up 한 줄로 Jenkins 서버와 앱 컨테이너가 함께 올라온다. 파이프라인 설정은 Jenkinsfile에, 환경 설정은 docker-compose.yml에 — 전부 코드로 관리된다.

핵심 결정:

결정 이유
Jenkins를 Docker로 실행 환경을 코드로 관리. docker compose up 한 줄로 전체 환경 구동
Pytest를 python:3.11-alpine 안에서 실행 Jenkins 호스트에 Python 설치 불필요
reuseNode true venv를 스테이지 간에 공유. 매 스테이지마다 재생성하지 않음
disableConcurrentBuilds() 동시 실행 시 발생하는 워크스페이스 @2 경로 충돌 방지
post { always { junit } } 실패해도 리포트는 남긴다. 디버깅에는 실패 데이터가 필요하다
docker.sock 마운트 Jenkins 컨테이너가 호스트 Docker 데몬에 접근해 docker compose 실행

파이프라인 단계:

Stage 실행 환경 역할
Checkout 호스트 (docker-node) GitHub에서 코드 수신
Set Up Python Env python:3.11-alpine venv 생성 + 의존성 설치
Run Pytest python:3.11-alpine 테스트 실행 + JUnit XML 생성
Deploy 호스트 (docker-node) docker compose up --build
JUnit Report 호스트 (docker-node) Jenkins UI에 테스트 결과 표시

사용 기술: Python, Pytest, Jenkins, Docker, docker-compose, GitHub Webhook, JUnit


Github: https://github.com/SangjinKO/cicd_pytest_docker_jenkins

Velog: https://velog.io/@kosang234/GitHub%EC%97%90-push%ED%95%98%EB%A9%B4-%ED%85%8C%EC%8A%A4%ED%8A%B8%EA%B0%80-%EB%8F%8C%EA%B3%A0-%ED%86%B5%EA%B3%BC%ED%95%98%EB%A9%B4-%EB%B0%B0%ED%8F%AC%EB%90%9C%EB%8B%A4-Jenkins-Pytest-Docker%EB%A1%9C-QA-%EC%9E%90%EB%8F%99%ED%99%94-%ED%8C%8C%EC%9D%B4%ED%94%84%EB%9D%BC%EC%9D%B8%EC%9D%84-%EC%A7%81%EC%A0%91-%EB%A7%8C%EB%93%A4%EB%A9%B4%EC%84%9C-%EA%B9%A8%EB%8B%AC%EC%9D%80-%EA%B2%83%EB%93%A4

QA

Leave a Comment: