--- apiVersion: tekton.dev/v1beta1 kind: Task metadata: name: git-version labels: app.kubernetes.io/version: "0.1" annotations: tekton.dev/pipelines.minVersion: "0.12.0" tekton.dev/displayName: "git version" tekton.dev/categories: Git tekton.dev/tags: git tekton.dev/platforms: "linux/amd64" spec: description: >- This task can be used to create a version from git history params: - name: gitversion-image default: gittools/gitversion:6.0.0-alpine.3.18-7.0 description: The name of the toolbox image type: string results: - description: The calculated git version you could use for git tagging e.g. "0.1.0-tektonize.1-188" name: gitVersion - description: A normalized version for use in container images e.g. "0.1.0-tektonize.1-188" name: packageVersion - name: shortSHA steps: - name: set-git-version image: $(params.gitversion-image) workingDir: $(workspaces.source.path) securityContext: runAsUser: 0 env: - name: PARAM_BRANCH value: $(params.branch) script: | #!/usr/bin/env ash ShortSha=$(/tools/dotnet-gitversion . /showvariable ShortSha) echo -n "${ShortSha}" | tee $(results.shortSHA.path) FullSemVer=$(/tools/dotnet-gitversion . /showvariable FullSemVer) echo -n "${FullSemVer}" | tee $(results.gitVersion.path) # normalize a bit because # image tags can only contain `abcdefghijklmnopqrstuvwxyz0123456789_-.ABCDEFGHIJKLMNOPQRSTUVWXYZ` PACKAGEVERSION=$(echo -n $FullSemVer | sed 's/[^-._0-9A-Za-z]/-/g') echo -n "${PACKAGEVERSION}" | tee $(results.packageVersion.path) workspaces: - name: source description: A workspace that contains the fetched git repository to create a version for.