diff --git a/.tekton/ansible-ai-connect-service-pull-request.yaml b/.tekton/ansible-ai-connect-service-pull-request.yaml index ae9dce63c..7e004ac96 100644 --- a/.tekton/ansible-ai-connect-service-pull-request.yaml +++ b/.tekton/ansible-ai-connect-service-pull-request.yaml @@ -215,19 +215,6 @@ spec: workspace: workspace - name: git-basic-auth workspace: git-auth - - - name: get-timestamp - taskSpec: - steps: - - name: output-timestamp - image: busybox - command: ["/bin/sh", "-c"] - args: - - echo -n $(date "+%Y%m%d%H%M") > $(results.time-stamp.path) - results: - - name: time-stamp - - - name: build-container params: - name: IMAGE @@ -247,7 +234,7 @@ spec: - name: BUILD_ARGS_FILE value: $(params.build-args-file) - name: BUILD_ARGS - value: ["IMAGE_TAGS=pr-{{pull_request_number}} pr-{{pull_request_number}}.$(tasks.get-timestamp.results.time-stamp)", "GIT_COMMIT=$(tasks.clone-repository.results.commit)"] + value: ["IMAGE_TAGS=pr-{{pull_request_number}} pr-{{pull_request_number}}.$(tasks.git-metadata.results.commit-timestamp)", "GIT_COMMIT=$(tasks.clone-repository.results.commit)"] runAfter: - prefetch-dependencies taskRef: @@ -272,7 +259,7 @@ spec: - name: IMAGE value: $(tasks.build-container.results.IMAGE_URL) - name: ADDITIONAL_TAGS - value: ["pr-{{pull_request_number}}", "pr-{{pull_request_number}}.$(tasks.get-timestamp.results.time-stamp)"] + value: ["pr-{{pull_request_number}}", "pr-{{pull_request_number}}.$(tasks.git-metadata.results.commit-timestamp)"] runAfter: - build-container taskRef: @@ -284,6 +271,26 @@ spec: - name: kind value: task resolver: bundles + - name: git-metadata + runAfter: + - clone-repository + workspaces: + - name: source + workspace: workspace + taskSpec: + workspaces: + - name: source + steps: + - name: get-commit-timestamp + image: alpine/git + script: | + #!/bin/sh + set -euo pipefail + cd "$(workspaces.source.path)/source" + + echo $(date -d @$(git log -1 --format=%at) "+%Y%m%d%H%M") > $(results.commit-timestamp.path) + results: + - name: commit-timestamp - name: build-source-image params: - name: BINARY_IMAGE diff --git a/.tekton/ansible-ai-connect-service-push.yaml b/.tekton/ansible-ai-connect-service-push.yaml index 3bc845798..e89766ddf 100644 --- a/.tekton/ansible-ai-connect-service-push.yaml +++ b/.tekton/ansible-ai-connect-service-push.yaml @@ -208,16 +208,6 @@ spec: workspace: workspace - name: git-basic-auth workspace: git-auth - - name: get-timestamp - taskSpec: - steps: - - name: output-timestamp - image: busybox - command: ["/bin/sh", "-c"] - args: - - echo -n $(date "+%Y%m%d%H%M") > $(results.time-stamp.path) - results: - - name: time-stamp - name: build-container params: - name: IMAGE @@ -237,7 +227,7 @@ spec: - name: BUILD_ARGS_FILE value: $(params.build-args-file) - name: BUILD_ARGS - value: ["IMAGE_TAGS=latest 1.0.$(tasks.get-timestamp.results.time-stamp)", "GIT_COMMIT=$(tasks.clone-repository.results.commit)"] + value: ["IMAGE_TAGS=latest 1.0.$(tasks.git-metadata.results.commit-timestamp)", "GIT_COMMIT=$(tasks.clone-repository.results.commit)"] runAfter: - prefetch-dependencies taskRef: @@ -262,7 +252,7 @@ spec: - name: IMAGE value: $(tasks.build-container.results.IMAGE_URL) - name: ADDITIONAL_TAGS - value: ["latest", "1.0.$(tasks.get-timestamp.results.time-stamp)"] + value: ["latest", "1.0.$(tasks.git-metadata.results.commit-timestamp)"] runAfter: - build-container taskRef: @@ -274,6 +264,26 @@ spec: - name: kind value: task resolver: bundles + - name: git-metadata + runAfter: + - clone-repository + workspaces: + - name: source + workspace: workspace + taskSpec: + workspaces: + - name: source + steps: + - name: get-commit-timestamp + image: alpine/git + script: | + #!/bin/sh + set -euo pipefail + cd "$(workspaces.source.path)/source" + + echo $(date -d @$(git log -1 --format=%at) "+%Y%m%d%H%M") > $(results.commit-timestamp.path) + results: + - name: commit-timestamp - name: build-source-image params: - name: BINARY_IMAGE