Skip to main content

Usage Examples

This guide provides practical examples of using BFCI Components in different scenarios.

Basic Pipeline Exampleโ€‹

A simple pipeline using test and lint components:

include:
- component: [COMPONENT_REGISTRY] / [email protected]
inputs:
test_command: 'npm test'
coverage_path: 'coverage'
- component: [COMPONENT_REGISTRY] / [email protected]
inputs:
lint_command: 'npm run lint'

stages:
- test
- lint

test:
extends: .test
stage: test

lint:
extends: .lint
stage: lint
```text

## Full CI / CD Pipeline
A complete pipeline with build, test, and deploy stages:

```yaml
include:
- component: [COMPONENT_REGISTRY] / [email protected]
inputs:
build_command: 'npm run build'
- component: [COMPONENT_REGISTRY] / [email protected]
inputs:
test_command: 'npm test'
coverage_path: 'coverage'
- component: [COMPONENT_REGISTRY] / [email protected]
inputs:
environment: 'production'
deploy_command: 'npm run deploy'

stages:
- build
- test
- deploy

build:
extends: .build
stage: build

test:
extends: .test
stage: test
needs: [build]

deploy:
extends: .deploy
stage: deploy
needs: [test]
only:
- main
```text

## React Application Example
Specialized configuration for React applications:

```yaml
include:
- component: [COMPONENT_REGISTRY] / [email protected]
inputs:
build_command: 'npm run build'
build_output: 'build'
- component: [COMPONENT_REGISTRY] / [email protected]
inputs:
test_command: 'npm test'
coverage_path: 'coverage'
test_setup: 'jest.setup.js'

variables:
NODE_ENV: production

cache:
key: [CI_COMMIT_REF_SLUG]
paths:
- node_modules/
- .npm/
```text

## Security Scanning Example
Adding security scans to your pipeline:

```yaml
include:
- component: [COMPONENT_REGISTRY] / [email protected]
inputs:
scan_type: 'sast'
target_dirs: 'src'
- component: [COMPONENT_REGISTRY] / [email protected]
inputs:
scan_type: 'dependency'
manifest_files: 'package.json'

stages:
- security

sast:
extends: .security - sast
stage: security

dependency - scan:
extends: .security - dependency
stage: security
```text

## Docker Build Example
Building and publishing Docker images:

```yaml
include:
- component: [COMPONENT_REGISTRY] / [email protected]
inputs:
dockerfile: 'Dockerfile'
image_name: 'my - app'
registry: 'registry.gitlab.bluefly.io'

stages:
- build

docker - build:
extends: .docker - build
stage: build
only:
- tags
```text

## Best Practices
1. Always specify component versions
2. Use cache effectively
3. Configure proper stage dependencies
4. Follow security guidelines
5. Implement proper error handling

## Common Patterns
- Multi - stage deployments
- Branch - specific configurations
- Environment - specific variables
- Artifact management
- Cache optimization

## Additional Resources
- [Component Registry Guide](. / component - registry.md)
- [Configuration Guide](. / configuration.md)
- [Security Best Practices](.. / components / security.md)