From 70d2f73be4f55627115c4cbcda16d1b0c3471c76 Mon Sep 17 00:00:00 2001 From: Mykola Serdiuk Date: Mon, 14 Oct 2024 16:49:02 +0300 Subject: [PATCH] fix: Update rpm default versioning (#339) --- charts/common-library/Chart.yaml | 4 +- charts/common-library/README.md | 2 +- charts/common-library/templates/_common.yaml | 3 +- charts/pipelines-library/Chart.lock | 6 +-- charts/pipelines-library/Chart.yaml | 2 +- charts/pipelines-library/README.md | 2 +- .../rpm/maven/bitbucket-build-default.yaml | 6 ++- .../rpm/maven/gerrit-build-default.yaml | 6 ++- .../rpm/maven/github-build-default.yaml | 6 ++- .../rpm/maven/gitlab-build-default.yaml | 7 ++- .../templates/tasks/cd/deploy-ansible.yaml | 2 +- .../templates/tasks/edp-rpm.yaml | 3 -- .../getversion/defaulttype/GetVersion.yaml | 1 - .../getversion/defaulttype/GetVersionRPM.yaml | 51 +++++++++++++++++++ 14 files changed, 82 insertions(+), 19 deletions(-) create mode 100644 charts/pipelines-library/templates/tasks/getversion/defaulttype/GetVersionRPM.yaml diff --git a/charts/common-library/Chart.yaml b/charts/common-library/Chart.yaml index bb6c118f..bc5f222b 100644 --- a/charts/common-library/Chart.yaml +++ b/charts/common-library/Chart.yaml @@ -3,8 +3,8 @@ description: A Helm chart library with common components for KubeRocketCI Tekton home: https://docs.kuberocketci.io name: edp-tekton-common-library type: library -version: 0.3.5 -appVersion: 0.3.5 +version: 0.3.6 +appVersion: 0.3.6 icon: https://docs.kuberocketci.io/img/logo.svg keywords: - edp diff --git a/charts/common-library/README.md b/charts/common-library/README.md index 96fdf07f..b12bd92a 100644 --- a/charts/common-library/README.md +++ b/charts/common-library/README.md @@ -1,6 +1,6 @@ # edp-tekton-common-library -![Version: 0.3.5](https://img.shields.io/badge/Version-0.3.5-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.3.5](https://img.shields.io/badge/AppVersion-0.3.5-informational?style=flat-square) +![Version: 0.3.6](https://img.shields.io/badge/Version-0.3.6-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.3.6](https://img.shields.io/badge/AppVersion-0.3.6-informational?style=flat-square) [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/epmdedp)](https://artifacthub.io/packages/search?repo=epmdedp) A Helm chart library with common components for KubeRocketCI Tekton Pipelines diff --git a/charts/common-library/templates/_common.yaml b/charts/common-library/templates/_common.yaml index 7c6e0553..76cfcb1c 100644 --- a/charts/common-library/templates/_common.yaml +++ b/charts/common-library/templates/_common.yaml @@ -202,9 +202,8 @@ - name: CBIS_NAME value: $(tasks.init-values.results.RESULT_IMAGE_NAME) - name: IMAGE_TAG - value: $(tasks.get-version.results.IS_TAG) + value: "$(tasks.get-version.results.IS_TAG)" {{- end -}} - # final section for gerrit codereview pipelines {{- define "gerrit-review-vote" -}} finally: diff --git a/charts/pipelines-library/Chart.lock b/charts/pipelines-library/Chart.lock index 7a3634d5..5bf79f14 100644 --- a/charts/pipelines-library/Chart.lock +++ b/charts/pipelines-library/Chart.lock @@ -1,9 +1,9 @@ dependencies: - name: edp-tekton-common-library repository: file://../common-library - version: 0.3.5 + version: 0.3.6 - name: tekton-cache repository: https://epam.github.io/edp-helm-charts/stable version: 0.3.2 -digest: sha256:bd87e325017748e96d3efa7b95a78c299e9ddc483975548626015860cffecc70 -generated: "2024-10-03T17:38:15.533831+03:00" +digest: sha256:bd44514da4c8bb7d5450905c8573ef13280f79bd195a37afa2e910e357e6753e +generated: "2024-10-14T19:28:03.095977+03:00" diff --git a/charts/pipelines-library/Chart.yaml b/charts/pipelines-library/Chart.yaml index e24380ed..9d832090 100644 --- a/charts/pipelines-library/Chart.yaml +++ b/charts/pipelines-library/Chart.yaml @@ -39,7 +39,7 @@ annotations: # we use templates from common library dependencies: - name: edp-tekton-common-library - version: 0.3.5 + version: 0.3.6 repository: "file://../common-library" - name: tekton-cache version: 0.3.2 diff --git a/charts/pipelines-library/README.md b/charts/pipelines-library/README.md index e6dd8fff..e3f92f0a 100644 --- a/charts/pipelines-library/README.md +++ b/charts/pipelines-library/README.md @@ -66,7 +66,7 @@ Follows [Tekton Interceptor](https://tekton.dev/vault/triggers-main/clusterinter | Repository | Name | Version | |------------|------|---------| | @epamedp | tekton-cache | 0.3.2 | -| file://../common-library | edp-tekton-common-library | 0.3.5 | +| file://../common-library | edp-tekton-common-library | 0.3.6 | ## Values diff --git a/charts/pipelines-library/templates/pipelines/rpm/maven/bitbucket-build-default.yaml b/charts/pipelines-library/templates/pipelines/rpm/maven/bitbucket-build-default.yaml index afea53a9..2579e6c4 100644 --- a/charts/pipelines-library/templates/pipelines/rpm/maven/bitbucket-build-default.yaml +++ b/charts/pipelines-library/templates/pipelines/rpm/maven/bitbucket-build-default.yaml @@ -73,7 +73,7 @@ spec: - name: get-version taskRef: kind: Task - name: get-version-default + name: get-version-rpm runAfter: - init-values params: @@ -81,6 +81,10 @@ spec: value: $(params.git-source-revision) - name: BASE_IMAGE value: $(params.image) + workspaces: + - name: source + subPath: source + workspace: shared-workspace {{- include "get-cache" $ | nindent 4 }} diff --git a/charts/pipelines-library/templates/pipelines/rpm/maven/gerrit-build-default.yaml b/charts/pipelines-library/templates/pipelines/rpm/maven/gerrit-build-default.yaml index d9c2d9d9..dd3a330f 100644 --- a/charts/pipelines-library/templates/pipelines/rpm/maven/gerrit-build-default.yaml +++ b/charts/pipelines-library/templates/pipelines/rpm/maven/gerrit-build-default.yaml @@ -70,7 +70,7 @@ spec: - name: get-version taskRef: kind: Task - name: get-version-default + name: get-version-rpm runAfter: - init-values params: @@ -78,6 +78,10 @@ spec: value: $(params.git-source-revision) - name: BASE_IMAGE value: $(params.image) + workspaces: + - name: source + subPath: source + workspace: shared-workspace {{- include "get-cache" $ | nindent 4 }} diff --git a/charts/pipelines-library/templates/pipelines/rpm/maven/github-build-default.yaml b/charts/pipelines-library/templates/pipelines/rpm/maven/github-build-default.yaml index 5c3c5a10..5cab5610 100644 --- a/charts/pipelines-library/templates/pipelines/rpm/maven/github-build-default.yaml +++ b/charts/pipelines-library/templates/pipelines/rpm/maven/github-build-default.yaml @@ -71,7 +71,7 @@ spec: - name: get-version taskRef: kind: Task - name: get-version-default + name: get-version-rpm runAfter: - init-values params: @@ -79,6 +79,10 @@ spec: value: $(params.git-source-revision) - name: BASE_IMAGE value: $(params.image) + workspaces: + - name: source + subPath: source + workspace: shared-workspace {{- include "get-cache" $ | nindent 4 }} diff --git a/charts/pipelines-library/templates/pipelines/rpm/maven/gitlab-build-default.yaml b/charts/pipelines-library/templates/pipelines/rpm/maven/gitlab-build-default.yaml index 227bc5d7..aba1a5cf 100644 --- a/charts/pipelines-library/templates/pipelines/rpm/maven/gitlab-build-default.yaml +++ b/charts/pipelines-library/templates/pipelines/rpm/maven/gitlab-build-default.yaml @@ -73,7 +73,7 @@ spec: - name: get-version taskRef: kind: Task - name: get-version-default + name: get-version-rpm runAfter: - init-values params: @@ -81,6 +81,11 @@ spec: value: $(params.git-source-revision) - name: BASE_IMAGE value: $(params.image) + workspaces: + - name: source + subPath: source + workspace: shared-workspace + {{- include "get-cache" $ | nindent 4 }} diff --git a/charts/pipelines-library/templates/tasks/cd/deploy-ansible.yaml b/charts/pipelines-library/templates/tasks/cd/deploy-ansible.yaml index 0acaeac8..cebb43c1 100644 --- a/charts/pipelines-library/templates/tasks/cd/deploy-ansible.yaml +++ b/charts/pipelines-library/templates/tasks/cd/deploy-ansible.yaml @@ -97,7 +97,7 @@ spec: "-i", inventory_path, ansible_group, "-m", "yum", - "-a", f"name={codebase} state=present allow_downgrade=true", + "-a", f"name={codebase}-{image_tag} state=present allow_downgrade=true", "-b", "--become" ] diff --git a/charts/pipelines-library/templates/tasks/edp-rpm.yaml b/charts/pipelines-library/templates/tasks/edp-rpm.yaml index 3c2f7560..5d347ddd 100644 --- a/charts/pipelines-library/templates/tasks/edp-rpm.yaml +++ b/charts/pipelines-library/templates/tasks/edp-rpm.yaml @@ -36,9 +36,6 @@ spec: type: string description: Current build version of application default: "1" - - name: CACHE_DIR - default: "/workspace/source/cache" - description: The path to the cache directory. - name: EXTRA_LINT_COMMAND type: string description: Run rpm lint command diff --git a/charts/pipelines-library/templates/tasks/getversion/defaulttype/GetVersion.yaml b/charts/pipelines-library/templates/tasks/getversion/defaulttype/GetVersion.yaml index 96d2d719..25da9d05 100644 --- a/charts/pipelines-library/templates/tasks/getversion/defaulttype/GetVersion.yaml +++ b/charts/pipelines-library/templates/tasks/getversion/defaulttype/GetVersion.yaml @@ -58,4 +58,3 @@ spec: printf "%s" "${VCS_TAG}" > "$(results.VCS_TAG.path)" printf "%s" "${IS_TAG}" > "$(results.IS_TAG.path)" printf "%s" "${BUILD_ID}" > "$(results.VERSION.path)" - printf "%s" "${NORMALIZED_VERSION}" > "$(results.NORMALIZED_VERSION.path)" diff --git a/charts/pipelines-library/templates/tasks/getversion/defaulttype/GetVersionRPM.yaml b/charts/pipelines-library/templates/tasks/getversion/defaulttype/GetVersionRPM.yaml new file mode 100644 index 00000000..1133ad2e --- /dev/null +++ b/charts/pipelines-library/templates/tasks/getversion/defaulttype/GetVersionRPM.yaml @@ -0,0 +1,51 @@ +apiVersion: tekton.dev/v1 +kind: Task +metadata: + name: get-version-rpm +spec: + description: | + This task generates a version number for the application based on the current timestamp and the branch name. + The version number is used to tag the image and the codebase image stream. + workspaces: + - description: A workspace that contains fetched git repo. + name: source + results: + - name: VERSION + description: "Application version" + - name: VCS_TAG + description: "VCS tag" + - name: IS_TAG + description: "CodebaseImageStream tag" + - name: TIMESTAMP + description: Current timestamp + - name: NORMALIZED_VERSION + description: Normalized version + steps: + - name: get-timestamp + image: alpine:3.18.9 + script: | + ts=$(date "+%Y%m%d-%H%M%S") + nts=$(date "+%Y%m%d.%H%M%S") + echo "Current Timestamp: ${ts}" + echo "Current Normalized Timestamp: ${nts}" + echo ${ts} | tr -d "\n" | tee $(results.TIMESTAMP.path) + echo ${nts} | tr -d "\n" | tee $(results.NORMALIZED_VERSION.path) + + - name: get-version + image: alpine/make:4.2.1 + workingDir: $(workspaces.source.path) + script: | + set -e + + VERSION=$(make version) + NORMALIZED_VERSION="$(cat $(results.NORMALIZED_VERSION.path))" + VCS_TAG="${VERSION}-${NORMALIZED_VERSION}" + IS_TAG="${VCS_TAG}" + + echo "VCS tag - ${VCS_TAG}" + echo "IS tag - ${IS_TAG}" + echo "Normalized Version - ${NORMALIZED_VERSION}" + + printf "%s" "${VERSION}" > "$(results.VERSION.path)" + printf "%s" "${VCS_TAG}" > "$(results.VCS_TAG.path)" + printf "%s" "${IS_TAG}" > "$(results.IS_TAG.path)"