Files
domain-incoming/share/gitea-tekton-org/tekton.dev_v1beta1_Task_generate-build-id.yaml
2024-04-25 15:51:35 +02:00

51 lines
1.7 KiB
YAML

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: generate-build-id
labels:
app.kubernetes.io/version: "0.1"
annotations:
tekton.dev/pipelines.minVersion: "0.12.1"
tekton.dev/categories: Build Tools
tekton.dev/tags: build-tool
tekton.dev/displayName: "buildid"
tekton.dev/platforms: "linux/amd64,linux/s390x,linux/ppc64le,linux/arm64"
spec:
description: >-
Given a base version, this task generates a unique build id by appending
the base-version to the current timestamp.
params:
- name: toolbox-image
default: sebt3/basic-toolbox-image:1.29.4
description: The name of the toolbox image
type: string
- name: branch
type: string
results:
- name: timestamp
description: Current timestamp
- name: commitcount
description: Current commitcount
- name: build-id
description: Current commitcount
steps:
- name: get-build-id
image: $(params.toolbox-image)
workingDir: $(workspaces.source.path)
script: |
#!/usr/bin/env bash
git config --global --add safe.directory /workspace/source
ts=`date "+%Y%m%d-%H%M%S"`
t2=`date "+%Y%m%d.%H%M%S"`
cc=`git rev-list --count HEAD`
buildId="$(params.branch)-${cc}.${t2}"
echo -n "Current Timestamp: "
echo -n ${ts} | tee $(results.timestamp.path)
echo -ne "\nCommit Count: "
echo -n ${cc} | tee $(results.commitcount.path)
echo -ne "\nBuild ID: "
echo -n ${buildId} | tee $(results.build-id.path)
workspaces:
- name: source
description: A workspace that contains the fetched git repository to create a version for.