Technical architectural analysis, practical configuration manifests, and deployment instructions for Bitbucket Pipelines CI/CD: DinD & Private.
image:
#Docker image options page
options:
#Global options page
clone:
#Git clone behavior page
definitions:
#Cache and service container definitions page
pipeline:
#Pipeline start options page
parallel:
#Parallel step options page
stage:
#Stage options page
step:
#Step options page
image
#private
image:
name: registry/image:tag
username: username
password: password
#public
image: registry/image:tag
options
Experimental feature, rarely used
#(premium-only) ๋์ผํ ์์
๊ณต๊ฐ ๋ด์ ๋ค๋ฅธ ์ ์ฅ์์ ํ์ดํ๋ผ์ธ ์ ์๋ฅผ ๊ณต์ ํ ์ง ์ฌ๋ถ๋ฅผ ์ง์ ํฉ๋๋ค.
export: true
options:
#max-time ์ต์
์ ๋จ๊ณ๊ฐ ์๊ฐ ์ด๊ณผ๋๊ธฐ ์ ๊น์ง ์คํํ ์ ์๋ ์ต๋ ์๊ฐ(๋ถ)์ ์ค์ ํฉ๋๋ค. max-time ์ต์
์ ์ ์ญ ์ต์
์์ฑ๊ณผ ๊ฐ๋ณ ํ์ดํ๋ผ์ธ ๋จ๊ณ๋ฅผ ๋ชจ๋ ์ฌ์ฉํ์ฌ ์ค์ ํ ์ ์์ต๋๋ค. ํ์ดํ๋ผ์ธ ๋จ๊ณ์ ๊ธฐ๋ณธ ์ต๋ ์๊ฐ์ 120๋ถ์
๋๋ค.
max-time: 30
#๊ธ๋ก๋ฒ docker ์ต์
์ ํ์ดํ๋ผ์ธ์ ๋ชจ๋ ๋จ๊ณ์ Docker ์๋น์ค๋ฅผ ์ถ๊ฐํฉ๋๋ค. ์ด Docker ์๋น์ค๋ฅผ ์ฌ์ฉํ๋ฉด ๋ชจ๋ ํ์ดํ๋ผ์ธ ๋จ๊ณ์์ Docker ๋ช
๋ น์ ์คํํ ์ ์์ต๋๋ค. Bitbucket ํ์ดํ๋ผ์ธ์์ Docker๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ํ ์์ธํ ๋ด์ฉ์ Bitbucket ํ์ดํ๋ผ์ธ์์ Docker ๋ช
๋ น ์คํ์ ์ฐธ์กฐํ์ธ์.
docker: true
#ํฌ๊ธฐ ์ต์
์ Bitbucket Cloud ์ธํ๋ผ๋ Linux Docker ์์ฒด ํธ์คํ
๋ฌ๋์์ ์คํํ ๋ ๋จ๊ณ๋ ์ ์ฒด ํ์ดํ๋ผ์ธ์ ์ถ๊ฐ ๋ฆฌ์์ค๋ฅผ ํ ๋นํฉ๋๋ค.
size: 2x
#๋จ๊ณ์ ์ ์ฉํ ๋ฐํ์ ๊ตฌ์ฑ์
๋๋ค.
runtime:
#ํด๋ผ์ฐ๋ ๋จ๊ณ์ ์ ์ฉํ ๋ฐํ์ ๊ตฌ์ฑ์
๋๋ค.
cloud:
#์ด ์ต์
์ ์์ /์ก์ ํธ๋ํฝ์ ๋ํ ๋จ๊ณ๋ฅผ ์คํํ ๋ ๊ธฐ๋ณธ aws-ip-ranges๋ฅผ ์ฌ์ฉํ ์ง ์๋๋ฉด atlassian-ip-ranges๋ฅผ ์ฌ์ฉํ ์ง ์ฌ๋ถ๋ฅผ ๋ํ๋
๋๋ค.
atlassian-ip-ranges: true
#์ด ์ต์
์ ๋จ๊ณ๋ฅผ ์คํํ ๋ ์ฌ์ฉํ ์ํคํ
์ฒ๋ฅผ ์ ์ดํฉ๋๋ค.
arch: arm
clone
#clone ์์ฑ์ ๋น๋ ์ค์ Bitbucket Pipelines๊ฐ ์ ์ฅ์๋ฅผ ๋ณต์ ํ๋ ๋ฐฉ๋ฒ์ ์ ์ดํ๋ ์ต์
์ ์ ๊ณตํฉ๋๋ค.
clone:
#Git ๋ณต์ ๋ณธ์ ๋นํ์ฑํํ ์ ์์ต๋๋ค. (pipelines.step.clone.enabled ์์ ํน์ step ํ์ฑํ ๊ฐ๋ฅ)
enabled: false
#lfs ์ต์
์ git clone ์์
์ค์ ์ ์ฅ์์ ๋ชจ๋ LFS ํ์ผ์ ๋ค์ด๋ก๋ํ๋๋ก git์ ์ง์ํฉ๋๋ค. lfs๋ฅผ ์ ์ญ ์ต์
์ผ๋ก true๋ก ์ค์ ํ๋ฉด ๋ชจ๋ LFS ํ์ผ์ด ๊ฐ ๋จ๊ณ ์์ ์ ๋ค์ด๋ก๋๋ฉ๋๋ค. lfs๋ฅผ ๊ฐ๋ณ ๋จ๊ณ์์ true๋ก ์ค์ ํ๋ฉด ํด๋น ๋จ๊ณ์ ๋ชจ๋ LFS ํ์ผ์ด ๋ค์ด๋ก๋๋ฉ๋๋ค. ๋น๋ ์๊ฐ๊ณผ ๋ฆฌ์์ค ์ฌ์ฉ๋์ ์ค์ด๋ ค๋ฉด ๊ฐ๋ณ ๋จ๊ณ์์ LFS๋ฅผ ์ฌ์ฉํ๊ฑฐ๋ ๊ฐ ๋จ๊ณ์ ํ์ํ ํ์ผ๋ง ๋ค์ด๋ก๋ํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
lfs: true
#๋ชจ๋ ํ์ดํ๋ผ์ธ ๋๋ ํ์ดํ๋ผ์ธ ๋จ๊ณ์ ๋ํ Git ๋ณต์ ๋ณธ์ ๊น์ด๋ฅผ ์ ์ํฉ๋๋ค. ์ ์ฒด ๋ณต์ ๋ณธ์ ๋ง๋ค๋ ค๋ฉด full์ ์ฌ์ฉํ์ธ์. ์ง์ ํ์ง ์์ผ๋ฉด ๊ธฐ๋ณธ๊ฐ์ ์ต๊ทผ 50๊ฐ ์ปค๋ฐ์
๋๋ค. Git ๋ณต์ ๊น์ด ์ต์
์ ๋ํ ์์ธํ ๋ด์ฉ์ Git ๋ฌธ์ โ git clone์ ์ฐธ์กฐํ์ธ์.
depth: 2
#skip-ssl-verify ์ต์
์ git clone ์ค์ SSL ๊ฒ์ฆ์ ๋นํ์ฑํํ์ฌ ์์ฒด ์๋ช
๋ ์ธ์ฆ์๋ฅผ ์ฌ์ฉํ ์ ์๋๋ก ํฉ๋๋ค.
skip-ssl-verify: true
definitions
#definitions ์์ฑ์ ํ์ดํ๋ผ์ธ ๊ตฌ์ฑ์ ๋ค๋ฅธ ๊ณณ์์ ์ฌ์ฉ๋๋ ๋ฆฌ์์ค๋ฅผ ์ ์ํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
definitions:
#Bitbucket Pipelines๋ ๋น๋ ์ข
์์ฑ๊ณผ ๋๋ ํ ๋ฆฌ ์บ์ฑ์ ์ง์ํ์ฌ ๋น๋ ์๋๋ฅผ ๋์ด๊ณ ์์๋๋ ๋น๋ ์๊ฐ์ ์ค์
๋๋ค. ๋ฏธ๋ฆฌ ์ ์๋ ์บ์๊ฐ ์ฌ๋ฌ ๊ฐ ์์ต๋๋ค. ๋ฏธ๋ฆฌ ์ ์๋ ์บ์์ ์ ์ฒด ๋ชฉ๋ก์ ์บ์ โ ๋ฏธ๋ฆฌ ์ ์๋ ์บ์๋ฅผ ์ฐธ์กฐํ์ธ์ .
caches:
#Bitbucket ํ์ดํ๋ผ์ธ์ ์๋น์ค๋ณ๋ก ๋ณ๋์ Docker ์ปจํ
์ด๋๋ฅผ ์์ฑํ ์ ์์ด ๋น๋ ์๋๊ฐ ๋นจ๋ผ์ง๊ณ ์๋น์ค ํธ์ง์ด ๊ฐํธํด์ง๋๋ค. ์๋น์ค ์์ฑ์ ๋ํ ์์ธํ ๋ด์ฉ์ ๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ฐ ์๋น์ค ์ปจํ
์ด๋๋ฅผ ์ฐธ์กฐํ์ธ์ . ์ด services์ต์
์ ์๋น์ค๋ฅผ ์ ์ํ์ฌ ํ์ดํ๋ผ์ธ ๋จ๊ณ์์ ์ฌ์ฉํ ์ ์๋๋ก ํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
services:
#service daemon image
image: registry/image:tag
#์ด memory์ต์
์ ์๋น์ค ์ปจํ
์ด๋์์ ์ฌ์ฉํ ์ ์๋ ๋ฉ๋ชจ๋ฆฌ(๋ฉ๊ฐ๋ฐ์ดํธ)๋ฅผ ์ ํํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. 4096MB( ๋น๋ 8192์ ๊ฒฝ์ฐ MB size: 2x)๋ ์คํฌ๋ฆฝํธ ๋ฐ ํ์ดํ๋ผ์ธ ์๋น์ค๋ฅผ ํฌํจํ์ฌ ์ ํ ๋นํ ์ ์๋ ์ด ๋ฉ๋ชจ๋ฆฌ ์์
๋๋ค step. ์๋ฅผ ๋ค์ด, ์๋น์ค์ 3072MB๊ฐ ํ์ํ ๊ฒฝ์ฐ 1024ํด๋น ์๋น์ค๋ฅผ ์ฌ์ฉํ์ฌ ๋จ๊ณ๋ฅผ ์คํํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋ ๋ฉ๋ชจ๋ฆฌ๋ MB๋ฟ์
๋๋ค. ์๋น์ค ์ปจํ
์ด๋ ๋ฉ๋ชจ๋ฆฌ ์ ํ์ ๋ํ ์์ธํ ๋ด์ฉ์ ๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ฐ ์๋น์ค ์ปจํ
์ด๋ - ์๋น์ค ๋ฉ๋ชจ๋ฆฌ ์ ํ์ ์ฐธ์กฐํ์ญ์์ค .
memory: 512
#์ด type์ต์
์ ๋ค์์ ์ํ Docker ์๋น์ค ์ปจํ
์ด๋(Docker-in-Docker ์คํ)๋ฅผ ์ง์ ํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. (--privileged ๋ถ๊ฐ๋ก docker-daemon ์ฌ์ฉ์ ์ํด ํ์ํจ.)
type: docker
#์๋น์ค variables์ต์
์ ์๋น์ค ์ปจํ
์ด๋์ ํ๊ฒฝ ๋ณ์๋ฅผ ์ ๋ฌํ๋ ๋ฐ ์ฌ์ฉ๋๋ฉฐ, ์ผ๋ฐ์ ์ผ๋ก ์๋น์ค๋ฅผ ๊ตฌ์ฑํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ์๋น์ค ์์ฑ์ ๋ํ ์์ธํ ๋ด์ฉ์ ๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ฐ ์๋น์ค ์ปจํ
์ด๋๋ฅผ ์ฐธ์กฐํ์ธ์ .
variables: [env]
#๋ฐ๋ณต๋๋ yaml ๊ตฌ์ฑ ์
์ ์ฌ์ ์ ์ํ๊ณ ์ฌ์ฌ์ฉ
{yamlAnchor}: [anchor]
-
features
-
Definitions for using a Docker-in-Docker (DIND) image from a private registry.
# private registry
definitions:
services:
custom-dind:
image:
name: { insecure-dind input }
username: "$private_docker_hub"
password: "$private_docker_hub_pw"
type: docker
variables:
DOCKER_OPTS: "--insecure-registry={ registry input }"
- Definitions for using a Docker-in-Docker (DIND) image from a public registry.
# public registry
definitions:
services:
custom-dind:
image: { insecure-dind input }
type: docker
variables:
DOCKER_OPTS: "--insecure-registry={ registry input }"
Yaml anchors
Predefine and reuse repeated yaml configuration sets
#์ ์: {$}
definitions:
steps:
- step: &build-test
name: Build and test
script:
- mvn package
artifacts:
- target/**
#์ฐธ์กฐ: {*}
pipelines:
branches:
develop:
- step: *build-test
main:
- step: *build-test
#์ฐธ์กฐ์ Overwrite: {<<: *}
ipelines:
branches:
develop:
- step: *build-test
main:
- step:
<<: *build-test
name: Testing on Main
- feature
- Use manual trigger for specific branches
definitions:
steps:
- step: &build-test
name: Build and test
script:
- mvn package
artifacts:
- target/**
- step: &deploy
name: Deploy
deployment: test
script:
- ./deploy.sh target/my-app.jar
pipelines:
branches:
develop:
- step: *build-test
- step: *deploy
main:
- step: *build-test
- step:
<<: *deploy
deployment: production
trigger: manual
pipeline
#ํ์ดํ๋ผ์ธ ์์ฑ์ ์ ์ฅ์์ ๋น๋ ํ๋ก์ธ์ค๋ฅผ ์ ์ํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ํ์ดํ๋ผ์ธ ์์ ์กฐ๊ฑด๊ณผ ํ์ดํ๋ผ์ธ ๋จ๊ณ๊ฐ ํฌํจ๋ฉ๋๋ค. ํ์ดํ๋ผ์ธ ์์ฑ์ ํ์์ด๋ฉฐ ์ ์ฅ์๋น ํ ๋ฒ๋ง ์ ์ํด์ผ ํฉ๋๋ค.
pipelines:
#๋ค๋ฅธ ์น์
์ ํ์ดํ๋ผ์ธ ์ ์์ ์ผ์นํ์ง ์๋ ๋ชจ๋ ๋ธ๋์น์ ๋ํ ํ์ดํ๋ผ์ธ ์ ์๋ฅผ ํฌํจํฉ๋๋ค.
default: [step]
#๋ชจ๋ ๋ธ๋์น๋ณ ๋น๋ ํ์ดํ๋ผ์ธ์ ์ ์ํฉ๋๋ค. ์ด ์น์
์ ์ด๋ฆ ๋๋ ํํ์์ Git ์ ์ฅ์์ ๋ธ๋์น์ ์ผ์นํฉ๋๋ค. Glob ํจํด์ ์ฌ์ฉํ์ฌ ๋ธ๋์น๋ฅผ ์ผ์น์ํฌ ์ ์์ต๋๋ค. Glob ํจํด์ ์ฌ์ฉํ์ฌ ๋ธ๋์น ์ด๋ฆ์ ์ผ์น์ํค๋ ๋ฐฉ๋ฒ์ ๋ํ ์์ธํ ๋ด์ฉ์ ํ์ดํ๋ผ์ธ YAML ํ์ผ์์ Glob ํจํด ์ฌ์ฉ์ ์ฐธ์กฐํ์ธ์.
branches:
main: [step]
"feature/*": [step]
#ํ ๋ฆฌํ์คํธ ์์ฑ์ ํ ๋ฆฌํ์คํธ๊ฐ ์์ฑ๋ ๋๋ง ์คํ๋๋ ํ์ดํ๋ผ์ธ์ ์ ์ํฉ๋๋ค. ์คํ ์ ์ ๋์ ๋ธ๋์น๋ฅผ ์์
๋ธ๋์น์ ๋ณํฉํฉ๋๋ค. ํฌํฌ๋ ์ ์ฅ์์ ํ ๋ฆฌํ์คํธ๋ ํ์ดํ๋ผ์ธ์ ํธ๋ฆฌ๊ฑฐํ์ง ์์ต๋๋ค. ๋ณํฉ์ด ์คํจํ๋ฉด ํ์ดํ๋ผ์ธ์ด ์ค์ง๋ฉ๋๋ค. ์ฐธ๊ณ : ํ ๋น๋ ๋ธ๋์น๋ ํ ๋ฆฌํ์คํธ์ ์์ค ๋ธ๋์น์ฌ์ผ ํฉ๋๋ค. ํ ๋ฆฌํ์คํธ ํ์ดํ๋ผ์ธ์ ์ ์๋ ๋ชจ๋ ๋ธ๋์น ๋ฐ ๊ธฐ๋ณธ ํ์ดํ๋ผ์ธ๊ณผ ํจ๊ป ์คํ๋๋ฏ๋ก ์ ์๊ฐ ๊ฒน์น๋ฉด ๋ ๊ฐ์ ํ์ดํ๋ผ์ธ์ด ๋์์ ์คํ๋ ์ ์์ต๋๋ค.
pull-requests:
main: [step]
"feature/*": [step]
#pr default
'**': [step]
#๋ชจ๋ ํ๊ทธ๋ณ ๋น๋ ํ์ดํ๋ผ์ธ์ ์ ์ํฉ๋๋ค. ์ด ์น์
์ ์ด๋ฆ์ด๋ ํํ์์ Git ์ ์ฅ์์ ํ๊ทธ ๋ฐ ์ฃผ์์ด ๋ฌ๋ฆฐ ํ๊ทธ์ ์ผ์นํฉ๋๋ค. Glob ํจํด์ ์ฌ์ฉํ์ฌ ํ๊ทธ๋ฅผ ์ผ์น์ํฌ ์ ์์ต๋๋ค.
tags:
"*-windows": [step]
"*-linux": [step]
#์ฌ์ฉ์ ์ง์ ์์ฑ์ Bitbucket Cloud ์ธํฐํ์ด์ค์์ ์๋์ผ๋ก๋ง ํธ๋ฆฌ๊ฑฐํ๊ฑฐ๋ ์์ฝํ ์ ์๋ ํ์ดํ๋ผ์ธ์ ์ ์ํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ์๋ ๋๋ ์์ฝ๋ ํ์ดํ๋ผ์ธ ์์ฑ์ ๋ํ ์์ธํ ๋ด์ฉ์ ์๋ ๋ฐ ์์ฝ๋ ํ์ดํ๋ผ์ธ ์์ฑ์ ์ฐธ์กฐํ์ธ์.
custom:
"defined-trigger-name1": [step]
"defined-trigger-name2": [step]
custom-trigger
stage
pipelines:
default:
#์คํ
์ด์ง๋ฅผ ์ฌ์ฉํ๋ฉด ๊ณต์ ์์ฑ์ ์ฌ์ฉํ์ฌ ํ์ดํ๋ผ์ธ ๋จ๊ณ๋ฅผ ๊ทธ๋ฃนํํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, ์คํ
์ด์ง๋ฅผ ์ฌ์ฉํ์ฌ ๋ฐฐํฌ์ ํ์ํ ๋จ๊ณ(์: ์ฑ ๋ฐฐํฌ ๋ฐ ๋ฐฐํฌ ์ฑ๊ณต ํ์ธ)๋ฅผ ๊ทธ๋ฃนํํ ์ ์์ต๋๋ค.
- stage:
name: name
steps: [step]
step
This step option is used to define the build execution unit. Each step is executed in the order it appears in the file bitbucket-pipelines.yml. A single pipeline can contain up to 100 stages.
Each step in the pipeline starts a separate Docker container to run the commands configured in its options. Each step can be customized using the following options:
runtimeโ Customize the runtime environment of the step.cloudatlassian-ip-rangesimageโUse a different Docker image.max-timeโSets the maximum time allowed for the step.cachesandservicesโfor specific caches and services.artifactsโHolds artifacts that can be used in subsequent steps.cloneโCustomize the Git clone operation for this step.-
triggermanualโSet a step to require a manual trigger before the pipeline can continue. -
features
-
self-hosted pipeline using custom defined service
pipelines:
branches:
"feature/pipeline-test":
- step:
name: "on-premise-agent :: Images push & Kubernetes Deploy"
runs-on:
- self.hosted
services:
- custom-dind
image: { client input }
script:
- docker info
parallel
pipelines:
default:
- step: # sequential step
name: Build
script:
- ./build.sh
- step: # sequential step
name: Build
script:
- ./build.sh
#parallel ์ต์
์ ์ฌ์ฉํ๋ฉด ์ฌ๋ฌ ๋จ๊ณ๋ฅผ ๋์์ ์คํํ์ฌ ์ฝ๋๋ฅผ ๋ ๋น ๋ฅด๊ฒ ๋น๋ํ๊ณ ํ
์คํธํ ์ ์์ต๋๋ค. ํ์ดํ๋ผ์ธ์์ ์ฌ์ฉํ๋ ์ด ๋น๋ ์๊ฐ์ ๋จ๊ณ๋ฅผ ๋ณ๋ ฌ๋ก ์ค์ ํด๋ ๋ณํ์ง ์์ง๋ง, ๊ฒฐ๊ณผ๋ฅผ ๋ ๋นจ๋ฆฌ ํ์ธํ ์ ์์ต๋๋ค. ํ์ดํ๋ผ์ธ ์ ์์ ํฌํจํ ์ ์๋ ์ด ๋จ๊ณ ์๋ ๋ณ๋ ฌ ๋๋ ์ง๋ ฌ ์คํ ์ฌ๋ถ์ ๊ด๊ณ์์ด 100๊ฐ๋ก ์ ํ๋ฉ๋๋ค.
- parallel: # these 2 steps will run in parallel
steps:
- step:
name: Integration 1
script:
- ./integration-tests.sh --batch 1
- step:
name: Integration 2
script:
- ./integration-tests.sh --batch 2
built-in
Caches
โ Pre-defined caches
The pipeline provides predefined cache locations for commonly used language tools.
| Cache name | In your step | Directories |
| [docker](https://support.atlassian.com/bitbucket-cloud/docs/run-docker-commands-in-bitbucket-pipelines/) |
caches:
|
n/a โ [Create a cache in the layers generated by the build.](https://support.atlassian.com/bitbucket-cloud/docs/run-docker-commands-in-bitbucket-pipelines/#RunDockercommandsinBitbucketPipelines-ci_caching) |
| composer |
caches:
|
~/.composer/cache
|
| dotnetcore |
caches:
|
~/.nuget/packages
|
| gradle |
caches:
|
~/.gradle/caches
|
| ivy2 |
caches:
|
~/.ivy2/cache
|
| maven |
caches:
|
~/.m2/repository
|
| node |
caches:
|
node_modules
|
| pip |
caches:
|
~/.cache/pip
|
|
sbt Note: To use the sbt tool, you must have both sbt and ivy2 caches enabled.
|
caches:
|
~/.sbt~/.ivy2/cache
|
Services
Backing service for using Docker daemon or configuring tests using DB
Pipeline services have the following limitations:
- Up to 5 services per step
- Memory limits as described below
- There is no REST API to access services and logs based on pipeline results.
- There is no mechanism to wait for the service to start.
- To run a larger number of small services, use Docker run or docker-compose
- Port 29418 is not available.
Features
Enterprise Cloud-si




Leave a Reply