パイプラインのアーティファクト
概要
Artifacts are files that are produced by a step. Once you've defined them in your pipeline configuration, you can share or export them.
Artifacts enable teams to share outputs between sequential pipeline steps or preserve them after execution completes. Common use cases include passing build artifacts to deployment stages or retaining test reports.
Key Constraints
Important Limitations
Files must reside within
BITBUCKET_CLONE_DIRat step completionGlob patterns starting with
*require quotation marksRelative path notation ("." and "..") is unsupported
Artifacts created in parallel steps may not be accessible to other steps within the same group
Retention window: 14 days maximum
Size limit: 1 GB per artifact
Artifact Types
Shared Artifacts
Accessible across multiple steps. Use shared artifacts for workflows that require sharing data between steps.
pipelines:
default:
- step:
name: Build
artifacts:
- dist/**
script:
- npm run build
- step:
name: Deploy
script:
- aws s3 sync dist/ s3://my-bucket/Scoped Artifacts
Scoped to each step and can't be downloaded across steps. Ideal for files like log files, test reports, screenshots, or videos.
- step:
name: Test
artifacts:
- name: Test Results
type: scoped
paths:
- test-results/**
- screenshots/**
script:
- npm testTest Report Artifacts
XML-only format for test ingestion, confined to single step scope.
- step:
name: Run Tests
artifacts:
- name: Test Reports
type: test-report
paths:
- test-results/*.xml
script:
- npm test基本的な構成
Simple Artifact
pipelines:
default:
- step:
name: Build
artifacts:
- build/**
- dist/**
script:
- npm run buildNamed Artifact
- step:
name: Build Application
artifacts:
- name: Production Build
paths:
- dist/**
- build/**
script:
- npm run buildArtifact Syntax
Basic Syntax (Flat Glob List)
The most common form is a flat list of glob patterns:
- step:
name: Build Application
script:
- npm run build
artifacts:
- dist/**
- build/**Structured Syntax
For more control, use the structured form with name and paths:
- step:
name: Build Application
script:
- npm run build
artifacts:
- name: Production Build
paths:
- dist/**
- build/**Artifact Configuration Fields
Required Fields (Structured Syntax Only)
When using the structured syntax, these fields are required:
フィールド | 説明 |
|---|---|
| Display label in UI |
| Glob patterns for file inclusion |
Optional Fields
フィールド | 説明 | 既定 |
|---|---|---|
| Artifact classification ( |
|
| Exclusion patterns | なし |
| Directory search depth | 無制限 |
| When to upload ( |
|
高度な構成
Exclude Files
- step:
artifacts:
- name: Build Output
paths:
- dist/**
ignore-paths:
- dist/**/*.map
- dist/**/*.log
script:
- npm run buildLimit Search Depth
- step:
artifacts:
- name: Top Level Only
paths:
- build/**
depth: 1
script:
- make buildCapture on Failure
- step:
name: Test with Screenshots
artifacts:
- name: Failure Screenshots
type: scoped
paths:
- screenshots/**
capture-on: failed
script:
- npm testAlways Capture
- step:
name: Test and Report
artifacts:
- name: Test Results
paths:
- test-results/**
- coverage/**
capture-on: always
script:
- npm test || trueDownload Control
Configure artifact retrieval using the download field:
Download All Artifacts (Default)
- step:
name: Deploy
script:
- ./deploy.shSkip All Artifacts
- step:
name: Lint
download: false
script:
- npm run lintDownload Specific Artifacts
pipelines:
default:
- step:
name: Build Frontend
artifacts:
- name: Frontend Build
paths:
- frontend/dist/**
script:
- cd frontend && npm run build
- step:
name: Build Backend
artifacts:
- name: Backend Build
paths:
- backend/build/**
script:
- cd backend && make build
- step:
name: Deploy Frontend Only
download:
- Frontend Build
script:
- aws s3 sync frontend/dist/ s3://my-bucket/File Permissions
Downloaded artifacts receive default permissions of 644 (-rw-r--r--).
To make files executable:
- step:
name: Deploy with Executable
script:
- chmod +x deploy.sh
- ./deploy.shCommon Use Cases
Build and Deploy
pipelines:
branches:
main:
- step:
name: Build
caches:
- node
artifacts:
- dist/**
script:
- npm install
- npm run build
- step:
name: Deploy to Production
deployment: production
script:
- aws s3 sync dist/ s3://production-bucket/Multi-Stage Build
pipelines:
default:
- step:
name: Compile
artifacts:
- name: Compiled Code
paths:
- build/**
script:
- make compile
- step:
name: Test
artifacts:
- name: Test Results
type: scoped
paths:
- test-results/**
script:
- make test
- step:
name: Package
download:
- Compiled Code
artifacts:
- name: Package
paths:
- dist/*.tar.gz
script:
- make packageParallel Builds
pipelines:
default:
- parallel:
- step:
name: Build Frontend
artifacts:
- name: Frontend
paths:
- frontend/dist/**
script:
- cd frontend && npm run build
- step:
name: Build Backend
artifacts:
- name: Backend
paths:
- backend/build/**
script:
- cd backend && make build
- step:
name: Deploy All
download:
- Frontend
- Backend
script:
- ./deploy-all.shTest Reports and Screenshots
pipelines:
default:
- step:
name: E2E Tests
artifacts:
- name: Test Results
type: test-report
paths:
- test-results/*.xml
- name: Failure Artifacts
type: scoped
paths:
- screenshots/**
- videos/**
capture-on: failed
script:
- npm run test:e2eArtifacts vs Caches
機能 | アーティファクト | キャッシュ |
|---|---|---|
目的 | Share build outputs | Speed up builds |
Retention | 14 days | 7 days |
Size Limit | 1 GB | 1 GB |
範囲 | Current pipeline | All pipelines |
When Created | After step completes | After successful step |
Best For | Compiled code, packages | Dependencies, node_modules |
Cross-Pipeline Artifacts
Artifacts can be passed between parent and child pipelines using artifacts: input: and artifacts: output: on a type: pipeline step. This extends the standard artifact model across pipeline boundaries.
# Parent passes its build artifact into a child, receives a report back
- step:
name: Security Scan
type: pipeline
custom: security-scan
artifacts:
input:
- app.tar.gz # parent artifact pushed into child
output:
- security-report.json # child artifact pulled back to parentAll the same artifact types (shared, scoped, test-report) and configurations (capture-on, ignore-paths, etc.) work the same way within the child pipeline. The parent simply defines which artifacts cross the boundary.
See the Pass artifacts as inputs and outputs across pipelines for full details and examples.
External Artifact Storage
For longer retention or larger files, use external storage:
AWS S3
- step:
name: Upload to S3
artifacts:
- dist/**
script:
- npm run build
- aws s3 sync dist/ s3://my-artifacts-bucket/$BITBUCKET_BUILD_NUMBER/JFrog Artifactory
- step:
name: Publish to Artifactory
script:
- npm run build
- curl -u$ARTIFACTORY_USER:$ARTIFACTORY_PASSWORD -T dist/app.zip "https://artifactory.example.com/repo/app-$BITBUCKET_BUILD_NUMBER.zip"Google Cloud Storage
- step:
name: Upload to GCS
script:
- npm run build
- gsutil -m cp -r dist/ gs://my-artifacts-bucket/$BITBUCKET_BUILD_NUMBER/Best Practices
Only artifact what you need - Smaller artifacts upload and download faster
Use specific patterns -
dist/**/*.jsis better than**/*Leverage ignore-paths - Exclude unnecessary files
Name artifacts clearly - Descriptive names help with debugging
Consider external storage - For files larger than 1GB or long-term retention
Use scoped for logs - Test reports and screenshots don't need to be shared
Set capture-on appropriately - Only capture failure artifacts when tests fail
Debugging Artifacts
If artifacts aren't working:
Verify paths exist - Files must be created before step completes
Check size - Must be under 1GB
Review patterns - Ensure glob patterns match your files
Check logs - Look for artifact upload messages
Test patterns locally - Use
ls dist/**to verify matches
次のステップ
Learn about Caching to speed up builds
Configure Deployments to use artifacts
Set up Service Containers for testing
Pass artifacts across pipeline boundaries with Pipelines: Artifacts Input/Output
この内容はお役に立ちましたか?