harness_pipeline_mainline - robjcook/sync GitHub Wiki
pipeline:
name: Mainline CI/CD
identifier: mainline_ci_cd
projectIdentifier: your_project_id
orgIdentifier: your_org_id
tags: {}
properties:
ci:
codebase:
connectorRef: your_git_connector
repoName: your-repo-name
build:
type: branch
spec:
branch: main
stages:
- stage:
name: CI Build
identifier: ci_build
type: CI
spec:
infrastructure:
type: KubernetesDirect
spec:
connectorRef: your_k8s_connector
namespace: harness-ci
execution:
steps:
- step:
name: Generate Version
identifier: generate_version
type: Run
spec:
shell: Bash
command: |
MAJOR=1
MINOR=0
PATCH=<+pipeline.sequenceId>
VERSION="${MAJOR}.${MINOR}.${PATCH}"
echo "export VERSION=$VERSION" >> $HARNESS_ENV_EXPORT_FILE
outputVariables:
- name: VERSION
- step:
name: Build and Push Image
identifier: build_image
type: Run
spec:
shell: Bash
command: |
echo "Building Docker image with tag: $VERSION"
docker build -t myregistry/myapp:$VERSION .
docker push myregistry/myapp:$VERSION
- stage:
name: CD Deploy
identifier: cd_deploy
type: Deployment
spec:
service:
serviceRef: your_service
environment:
environmentRef: your_environment
deployToAll: true
infrastructure:
infrastructureDefinition:
type: KubernetesDirect
spec:
connectorRef: your_k8s_connector
namespace: your-namespace
execution:
steps:
- step:
name: Helm Deploy
identifier: helm_deploy
type: HelmDeploy
spec:
chart:
store:
type: Git
spec:
connectorRef: your_git_connector
repoName: your-helm-repo
chartPath: charts/myapp
branch: main
chartName: myapp
version: <+pipeline.stages.ci_build.spec.execution.steps.generate_version.output.outputVariables.VERSION>
valuesYaml: |
image:
repository: myregistry/myapp
tag: <+pipeline.stages.ci_build.spec.execution.steps.generate_version.output.outputVariables.VERSION>