From f95e6e0c7f421e8a0315d567608068ce3f92b47c Mon Sep 17 00:00:00 2001 From: Sergiy Kulanov Date: Fri, 12 Jan 2024 17:47:10 +0200 Subject: [PATCH] feat!: Align promotion procedure to the new format (#96) Switch from app=ver1 app2=ver2 to JSON format {"app": "ver1", "app2": "ver2"} JIRA: EPMDEDP-13010 BREAKING CHANGE: We need to change format of payload that we pass to CD Pipeline Signed-off-by: Sergiy Kulanov Change-Id: Id348688c12e7ae34e716367033478b3794ee977c --- .../templates/pipelines/cd/cd-stage-deploy.yaml | 14 ++++++++++++++ .../templates/tasks/promote-images.yaml | 17 ++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/charts/pipelines-library/templates/pipelines/cd/cd-stage-deploy.yaml b/charts/pipelines-library/templates/pipelines/cd/cd-stage-deploy.yaml index aa2307b7..ee9547d5 100644 --- a/charts/pipelines-library/templates/pipelines/cd/cd-stage-deploy.yaml +++ b/charts/pipelines-library/templates/pipelines/cd/cd-stage-deploy.yaml @@ -68,3 +68,17 @@ spec: - name: EXTRA_COMMANDS value: echo "Hello World" + + - name: promote-images + taskRef: + kind: Task + name: promote-images + runAfter: + - post-deploy + params: + - name: APPLICATIONS_PAYLOAD + value: $(params.APPLICATIONS_PAYLOAD) + - name: CDPIPELINE_STAGE + value: $(params.CDSTAGE) + - name: CDPIPELINE_CR + value: $(params.CDPIPELINE) diff --git a/charts/pipelines-library/templates/tasks/promote-images.yaml b/charts/pipelines-library/templates/tasks/promote-images.yaml index 4fbcd047..5f7a0a17 100644 --- a/charts/pipelines-library/templates/tasks/promote-images.yaml +++ b/charts/pipelines-library/templates/tasks/promote-images.yaml @@ -7,19 +7,17 @@ spec: - name: BASE_IMAGE description: The base image for the task. type: string - default: bitnami/kubectl:1.25.4 - - name: CODEBASE_TAG - description: "Codebases with a tag, separated by tabs. Example: foo=1.23 bar=master-1 baz=0.0.1-SNAPSHOT" + default: sergk/edp-argocd-cli:0.2.0-dev + - name: APPLICATIONS_PAYLOAD + description: | + Applications payload in format: '{"codebase1": "version1", "codebase2": "version2"}. For example: '{"demo": "main-20240103-141431", "myapp": "0.1.0-SNAPSHOT.1"}' type: string - default: "" - name: CDPIPELINE_CR description: CDPipeline custom resource name type: string - default: "" - name: CDPIPELINE_STAGE description: Stage name in CD Pipeline type: string - default: "" - name: CBIS_CRD description: CodebaseImageStream custom resource definition. type: string @@ -32,12 +30,13 @@ spec: description: CDPipeline custom resource definition. type: string default: "cdpipelines.v2.edp.epam.com" + steps: - name: annotate image: $(params.BASE_IMAGE) env: - - name: CODEBASE_TAG - value: "$(params.CODEBASE_TAG)" + - name: APPLICATIONS_PAYLOAD + value: "$(params.APPLICATIONS_PAYLOAD)" - name: CDPIPELINE_CR value: "$(params.CDPIPELINE_CR)" - name: CDPIPELINE_STAGE @@ -47,7 +46,7 @@ spec: script: | set -ex STAGE_CR="${CDPIPELINE_CR}-${CDPIPELINE_STAGE}" - for i in ${CODEBASE_TAG}; do + echo ${APPLICATIONS_PAYLOAD} | jq -r 'to_entries[] | "\(.key)=\(.value)"' | while read i; do kubectl annotate --overwrite "${STAGE_CRD}" "${STAGE_CR}" "app.edp.epam.com/${i}" done - name: promote-images