From 61ab8e5afde1268801829da257f535242a6e49d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Huss?= Date: Thu, 25 Apr 2024 15:40:15 +0200 Subject: [PATCH] fix --- share/gitea-tekton-org/index.rhai | 1 - .../tekton.dev_v1_Pipeline_auto-ci-push.yaml | 8 ++-- ...on.dev_v1beta1_Task_generate-build-id.yaml | 37 +++++++++++++------ .../tekton.dev_v1beta1_Task_git-clone.yaml | 9 ----- .../v1_ConfigMap_auto-cd-templates.yaml | 4 +- 5 files changed, 31 insertions(+), 28 deletions(-) diff --git a/share/gitea-tekton-org/index.rhai b/share/gitea-tekton-org/index.rhai index 3ee9687..eb3a3aa 100644 --- a/share/gitea-tekton-org/index.rhai +++ b/share/gitea-tekton-org/index.rhai @@ -7,7 +7,6 @@ const sources=[ #{url: "https://github.com/tektoncd/catalog/raw/main/task/buildpacks-phases/0.2/buildpacks-phases.yaml", name: "buildpacks-phases.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/buildpacks/0.6/buildpacks.yaml", name: "buildpacks.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/check-make/0.1/check-make.yaml", name: "check-make.yaml"}, - #{url: "https://github.com/tektoncd/catalog/raw/main/task/generate-build-id/0.1/generate-build-id.yaml", name: "generate-build-id.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/gitea-set-status/0.1/gitea-set-status.yaml", name: "gitea-set-status.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/hadolint/0.1/hadolint.yaml", name: "hadolint.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/hugo/0.1/hugo.yaml", name: "hugo.yaml"}, diff --git a/share/gitea-tekton-org/tekton.dev_v1_Pipeline_auto-ci-push.yaml b/share/gitea-tekton-org/tekton.dev_v1_Pipeline_auto-ci-push.yaml index df0001c..f05e805 100644 --- a/share/gitea-tekton-org/tekton.dev_v1_Pipeline_auto-ci-push.yaml +++ b/share/gitea-tekton-org/tekton.dev_v1_Pipeline_auto-ci-push.yaml @@ -118,17 +118,17 @@ spec: workspace: source - name: ssh-directory workspace: ssh - - name: git-version + - name: generate-build-id runAfter: [git-clone] params: - name: branch value: $(params.branch-name) taskRef: - name: git-version + name: generate-build-id workspaces: - name: source - name: detect-stages - runAfter: [git-version] + runAfter: [generate-build-id] params: - name: pipeline-type value: push @@ -139,7 +139,7 @@ spec: - name: project-path value: $(params.project-path) - name: image-version - value: "$(params.branch-name)-$(tasks.git-version.results.packageVersion)" + value: "$(tasks.generate-build-id.results.build-id)" taskRef: name: auto-ci-detector workspaces: diff --git a/share/gitea-tekton-org/tekton.dev_v1beta1_Task_generate-build-id.yaml b/share/gitea-tekton-org/tekton.dev_v1beta1_Task_generate-build-id.yaml index 14b7c0c..3534792 100644 --- a/share/gitea-tekton-org/tekton.dev_v1beta1_Task_generate-build-id.yaml +++ b/share/gitea-tekton-org/tekton.dev_v1beta1_Task_generate-build-id.yaml @@ -16,27 +16,40 @@ spec: the base-version to the current timestamp. params: - - name: base-version - description: Base product version + - name: toolbox-image + default: sebt3/basic-toolbox-image:1.29.4 + description: The name of the toolbox image + type: string + - name: branch type: string - default: "1.0" results: - name: timestamp description: Current timestamp + - name: commitcount + description: Current commitcount - name: build-id - description: ID of the current build + description: Current commitcount steps: - name: get-timestamp - image: docker.io/library/bash:5.0.18@sha256:879f94a9da53dc064779e7a68339aecd60a9028ff884cacaa47ae752ca690404 #tag: 5.0.18 + image: $(params.toolbox-image) script: | #!/usr/bin/env bash ts=`date "+%Y%m%d-%H%M%S"` - echo "Current Timestamp: ${ts}" - echo ${ts} | tr -d "\n" | tee $(results.timestamp.path) - - name: get-buildid - image: docker.io/library/bash:5.0.18@sha256:879f94a9da53dc064779e7a68339aecd60a9028ff884cacaa47ae752ca690404 #tag: 5.0.18 + echo -n "Current Timestamp: " + echo -n ${ts} | tee $(results.timestamp.path) + - name: get-commitcount + image: $(params.toolbox-image) script: | #!/usr/bin/env bash - ts=`cat $(results.timestamp.path)` - buildId=$(inputs.params.base-version)-${ts} - echo ${buildId} | tr -d "\n" | tee $(results.build-id.path) \ No newline at end of file + cc=`git rev-list --count HEAD` + echo -n "Commit Count: " + echo -n ${cc} | tee $(results.commitcount.path) + - name: get-build-id + image: $(params.toolbox-image) + script: | + #!/usr/bin/env bash + ts=`cat $(results.timestamp.path)|sed 's/-/./` + cc=`cat $(results.commitcount.path)` + buildId="$(params.branch)-${cc}.${ts}" + echo -n "Build ID: " + echo -n ${buildId} | tee $(results.build-id.path) \ No newline at end of file diff --git a/share/gitea-tekton-org/tekton.dev_v1beta1_Task_git-clone.yaml b/share/gitea-tekton-org/tekton.dev_v1beta1_Task_git-clone.yaml index e544032..7a9b4f4 100644 --- a/share/gitea-tekton-org/tekton.dev_v1beta1_Task_git-clone.yaml +++ b/share/gitea-tekton-org/tekton.dev_v1beta1_Task_git-clone.yaml @@ -243,15 +243,6 @@ spec: git remote add origin "${PARAM_URL}" git fetch "--recurse-submodules=${PARAM_SUBMODULES}" $FETCH_CMD origin --update-head-ok --force git reset --hard "${PARAM_REVISION}" - #/ko-app/git-init \ - # -url="${PARAM_URL}" \ - # -revision="${PARAM_REVISION}" \ - # -refspec="${PARAM_REFSPEC}" \ - # -path="${CHECKOUT_DIR}" \ - # -sslVerify="${PARAM_SSL_VERIFY}" \ - # -submodules="${PARAM_SUBMODULES}" \ - # -depth="${PARAM_DEPTH}" \ - # -sparseCheckoutDirectories="${PARAM_SPARSE_CHECKOUT_DIRECTORIES}" cd "${CHECKOUT_DIR}" RESULT_SHA="$(git rev-parse HEAD)" EXIT_CODE="$?" diff --git a/share/gitea-tekton-org/v1_ConfigMap_auto-cd-templates.yaml b/share/gitea-tekton-org/v1_ConfigMap_auto-cd-templates.yaml index 0d3e18f..d1501c2 100644 --- a/share/gitea-tekton-org/v1_ConfigMap_auto-cd-templates.yaml +++ b/share/gitea-tekton-org/v1_ConfigMap_auto-cd-templates.yaml @@ -238,7 +238,7 @@ data: imageRepositoryRef: name: ${PROJECT_NAME}-repo filterTags: - pattern: '^v(?P.*)$' + pattern: '^v(?P(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)' extract: '$semver' policy: semver: @@ -256,7 +256,7 @@ data: imageRepositoryRef: name: ${PROJECT_NAME}-repo filterTags: - pattern: '^main-(?P.*)$' + pattern: '^main-(?P(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)' extract: '$semver' policy: semver: