Skip to content

Commit

Permalink
chore: Enable deployment env variables in CD pipelines(#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr_taruraiev committed Nov 14, 2024
1 parent ee79043 commit 386e5fd
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ spec:
default: "master"
- name: stage-name
default: "dev"
- name: cd-pipeline-name
default: "dev"
- name: base-image
default: ""
tasks:
Expand Down
12 changes: 10 additions & 2 deletions charts/pipelines-library/templates/pipelines/cd/clean.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ spec:
kind: Task
name: run-clean-gate
params:
- name: PIPELINE
value: $(params.CDPIPELINE)
- name: STAGE
value: $(params.CDSTAGE)
- name: KUBECONFIG_SECRET_NAME
value: $(params.KUBECONFIG_SECRET_NAME)
- name: BASE_IMAGE
value: "bitnami/kubectl:1.25.4"
value: "{{ include "edp-tekton.registry" . }}/bitnami/kubectl:1.25.4"
- name: EXTRA_COMMANDS
value:
echo "Hello World"
Expand All @@ -56,10 +60,14 @@ spec:
runAfter:
- clean
params:
- name: PIPELINE
value: $(params.CDPIPELINE)
- name: STAGE
value: $(params.CDSTAGE)
- name: KUBECONFIG_SECRET_NAME
value: $(params.KUBECONFIG_SECRET_NAME)
- name: BASE_IMAGE
value: "bitnami/kubectl:1.25.4"
value: "{{ include "edp-tekton.registry" . }}/bitnami/kubectl:1.25.4"
- name: EXTRA_COMMANDS
value:
echo "Hello World"
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ spec:
kind: Task
name: run-quality-gate
params:
- name: PIPELINE
value: $(params.CDPIPELINE)
- name: STAGE
value: $(params.CDSTAGE)
- name: BASE_IMAGE
value: "{{ include "edp-tekton.registry" . }}/bitnami/kubectl:1.25.4"
- name: EXTRA_COMMANDS
Expand Down Expand Up @@ -62,6 +66,10 @@ spec:
runAfter:
- deploy-app
params:
- name: PIPELINE
value: $(params.CDPIPELINE)
- name: STAGE
value: $(params.CDSTAGE)
- name: BASE_IMAGE
value: "{{ include "edp-tekton.registry" . }}/bitnami/kubectl:1.25.4"
- name: EXTRA_COMMANDS
Expand All @@ -75,6 +83,10 @@ spec:
runAfter:
- post-deploy
params:
- name: PIPELINE
value: $(params.CDPIPELINE)
- name: STAGE
value: $(params.CDSTAGE)
- name: APPLICATIONS_PAYLOAD
value: $(params.APPLICATIONS_PAYLOAD)
- name: CDPIPELINE_STAGE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ spec:
kind: Task
name: run-quality-gate
params:
- name: PIPELINE
value: $(params.CDPIPELINE)
- name: STAGE
value: $(params.CDSTAGE)
- name: BASE_IMAGE
value: "{{ include "edp-tekton.registry" . }}/bitnami/kubectl:1.25.4"
- name: EXTRA_COMMANDS
Expand Down Expand Up @@ -58,6 +62,10 @@ spec:
runAfter:
- deploy-app
params:
- name: PIPELINE
value: $(params.CDPIPELINE)
- name: STAGE
value: $(params.CDSTAGE)
- name: BASE_IMAGE
value: "{{ include "edp-tekton.registry" . }}/bitnami/kubectl:1.25.4"
- name: EXTRA_COMMANDS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ spec:
kind: Task
name: run-quality-gate
params:
- name: PIPELINE
value: $(params.CDPIPELINE)
- name: STAGE
value: $(params.CDSTAGE)
- name: KUBECONFIG_SECRET_NAME
value: $(params.KUBECONFIG_SECRET_NAME)
- name: BASE_IMAGE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ spec:
kind: Task
name: run-quality-gate
params:
- name: PIPELINE
value: $(params.CDPIPELINE)
- name: STAGE
value: $(params.CDSTAGE)
- name: KUBECONFIG_SECRET_NAME
value: $(params.KUBECONFIG_SECRET_NAME)
- name: BASE_IMAGE
Expand Down Expand Up @@ -71,6 +75,10 @@ spec:
runAfter:
- deploy-app
params:
- name: PIPELINE
value: $(params.CDPIPELINE)
- name: STAGE
value: $(params.CDSTAGE)
- name: KUBECONFIG_SECRET_NAME
value: $(params.KUBECONFIG_SECRET_NAME)
- name: BASE_IMAGE
Expand Down
8 changes: 8 additions & 0 deletions charts/pipelines-library/templates/pipelines/cd/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ spec:
kind: Task
name: run-quality-gate
params:
- name: PIPELINE
value: $(params.CDPIPELINE)
- name: STAGE
value: $(params.CDSTAGE)
- name: KUBECONFIG_SECRET_NAME
value: $(params.KUBECONFIG_SECRET_NAME)
- name: BASE_IMAGE
Expand Down Expand Up @@ -63,6 +67,10 @@ spec:
runAfter:
- deploy-app
params:
- name: PIPELINE
value: $(params.CDPIPELINE)
- name: STAGE
value: $(params.CDSTAGE)
- name: KUBECONFIG_SECRET_NAME
value: $(params.KUBECONFIG_SECRET_NAME)
- name: BASE_IMAGE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ spec:
value: $(params.cd-pipeline-name)
- name: PARENT_PIPELINE_NAME
value: $(params.parent-pipeline-name)

envFrom:
- configMapRef:
name: $(params.cd-pipeline-name)-$(params.stage-name)
script: |
#!/usr/bin/env python
Expand Down Expand Up @@ -103,6 +105,7 @@ spec:
-p git-source-url=" + gitAutotesUrl[count] + " \
-p git-source-revision=" + autotestsBranch[count] + " \
-p stage-name=" + stage +" \
-p cd-pipeline-name=" + cdPipelineName +" \
-p base-image=" + frameworks[autotestBuildTool[count] + "-" + autotestFramework[count]] + " \
--labels app.edp.epam.com/pipeline=" + cdPipelineName + " \
--labels app.edp.epam.com/stage=" + stage + " \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ spec:
- name: source
description: A workspace that contains the repository.
params:
- name: cd-pipeline-name
type: string
- name: stage-name
type: string
- name: base-image
Expand All @@ -30,6 +32,11 @@ spec:
env:
- name: STAGE_NAME
value: $(params.stage-name)
- name: CD_PIPELINE_NAME
value: $(params.cd-pipeline-name)
envFrom:
- configMapRef:
name: $(params.cd-pipeline-name)-$(params.stage-name)
script: |
#!/bin/bash
Expand Down
3 changes: 3 additions & 0 deletions charts/pipelines-library/templates/tasks/cd/clean.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ spec:
secretKeyRef:
name: ci-argocd
key: token
envFrom:
- configMapRef:
name: $(params.PIPELINE)-$(params.STAGE)
script: |
set -ex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ spec:
secretKeyRef:
name: ci-awx
key: password
envFrom:
- configMapRef:
name: $(params.PIPELINE)-$(params.STAGE)
script: |
#!/usr/bin/env sh
set -eu
tower-cli config host ${AWX_HOST}
tower-cli config username ${AWX_USERNAME}
tower-cli config username ${AWX_USERNAME}
tower-cli config password ${AWX_PASSWORD}
tower-cli config verify_ssl false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ spec:
secretKeyRef:
name: ci-nexus
key: password
envFrom:
- configMapRef:
name: $(params.PIPELINE)-$(params.STAGE)
script: |
#!/usr/bin/env python
import os
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ spec:
secretName: $(params.KUBECONFIG_SECRET_NAME)
optional: true
params:
- description: >
EDP kind:CDPipeline name used for deployment. For example: mypipe,
myfeature
name: PIPELINE
type: string
- description: >
EDP kind:Stage name of the kind:CDPipeline defined in the CDPIPELINE
values. For example: dev, test, prod
name: STAGE
type: string
- name: BASE_IMAGE
description: The base image for the task (different for buildtools).
type: string
Expand All @@ -29,6 +39,9 @@ spec:
volumeMounts:
- name: kubeconfig
mountPath: /workspace/source/kube
envFrom:
- configMapRef:
name: $(params.PIPELINE)-$(params.STAGE)
script: |
set -ex
export KUBECONFIG="workspace/source/kube/config"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ spec:
secretName: $(params.KUBECONFIG_SECRET_NAME)
optional: true
params:
- description: >
EDP kind:CDPipeline name used for deployment. For example: mypipe,
myfeature
name: PIPELINE
type: string
- description: >
EDP kind:Stage name of the kind:CDPipeline defined in the CDPIPELINE
values. For example: dev, test, prod
name: STAGE
type: string
- name: BASE_IMAGE
description: The base image for the task (different for buildtools).
type: string
Expand All @@ -29,6 +39,9 @@ spec:
volumeMounts:
- name: kubeconfig
mountPath: /workspace/source/kube
envFrom:
- configMapRef:
name: $(params.PIPELINE)-$(params.STAGE)
script: |
set -ex
export KUBECONFIG="workspace/source/kube/config"
Expand Down

0 comments on commit 386e5fd

Please sign in to comment.