diff --git a/tasks/after-pipeline/task.yaml b/tasks/after-pipeline/task.yaml index d3cd71c..65c7ea5 100644 --- a/tasks/after-pipeline/task.yaml +++ b/tasks/after-pipeline/task.yaml @@ -20,14 +20,14 @@ spec: The name of the folder in the shared workspace to delete. If empty, no cleanup action will be performed. workspaces: - - name: shared + - name: base steps: - name: cleanup-folder image: ubuntu script: | #!/bin/bash - base="/workspace/shared/$(params.base)" + base="/workspace/base/$(params.base)" if [ -d "${base}" ]; then rm -rf "${base}" echo "Deleted folder: ${base}" diff --git a/tasks/before-pipeline/task.yaml b/tasks/before-pipeline/task.yaml index fad0666..aa16416 100644 --- a/tasks/before-pipeline/task.yaml +++ b/tasks/before-pipeline/task.yaml @@ -20,27 +20,19 @@ spec: A prefix for the working folder name. The final folder name will include this prefix, a timestamp, and a random string. results: - - name: base + - name: context description: | The unique folder name created in the shared workspace. - - name: home - description: | - The unique home folder name created in the shared workspace. - - name: workshop - description: | - The unique working folder name created in the shared workspace. workspaces: - - name: shared + - name: base steps: - name: create-folder image: ubuntu script: | #!/bin/bash - uniqueFolder="$(params.workingFolderPrefix)-$(date +%s)-$(head /dev/urandom | tr -dc a-z0-9 | head -c 6)" - mkdir -p /workspace/shared/${uniqueFolder}/workshop - mkdir -p /workspace/shared/${uniqueFolder}/home - chmod -R a+rwX /workspace/shared/${uniqueFolder} - echo "Created folder: ${uniqueFolder}/{workshop | home}" - echo -n "${uniqueFolder}" > $(results.base.path) - echo -n "${uniqueFolder}/workshop" > $(results.workshop.path) - echo -n "${uniqueFolder}/home" > $(results.home.path) + context="$(params.workingFolderPrefix)-$(date +%s)-$(head /dev/urandom | tr -dc a-z0-9 | head -c 6)" + mkdir -p /workspace/base/${context}/source + mkdir -p /workspace/base/${context}/home + chmod -R a+rwX /workspace/base/${context} + echo "Created folder: ${context}/{source | home}" + echo -n "${context}" > $(results.context.path) diff --git a/tasks/docker-registry/task.yaml b/tasks/docker-registry/task.yaml index 5e967a9..26c1b7b 100644 --- a/tasks/docker-registry/task.yaml +++ b/tasks/docker-registry/task.yaml @@ -4,15 +4,10 @@ metadata: name: docker-registry spec: params: - - name: home + - name: context type: string default: "" - description: home directory - - - name: workshop - type: string - default: "" - description: workshop within the repo where the source code is located + description: context directory - name: imageName type: string @@ -27,14 +22,14 @@ spec: default: ./Dockerfile description: Path to Dockerfile - - name: context + - name: dockerContext type: string default: . description: Build context path (relative to workshop) workspaces: - - name: shared - description: Source code workspace + - name: base + description: base workspace results: - name: imageUrl @@ -43,11 +38,6 @@ spec: steps: - name: prepare-docker image: alpine:3.21.3 - workingDir: /workspace/shared/$(params.workshop) - env: - - name: HOME - value: /workspace/shared/$(params.home) - script: | #!/bin/sh set -e @@ -58,17 +48,17 @@ spec: - name: kaniko-build image: gcr.io/kaniko-project/executor:v1.23.2 - workingDir: $(workspaces.shared.path)/$(params.workshop) + workingDir: /workspace/base/$(params.context)/source env: - name: HOME - value: /workspace/shared/$(params.home) + value: /workspace/base/$(params.context)/home - name: DOCKER_CONFIG - value: /workspace/shared/$(params.home)/.docker + value: /workspace/base/$(params.context)/home/.docker command: - /kaniko/executor args: - --dockerfile=$(params.dockerfile) - - --context=$(params.context) + - --context=$(params.dockerContext) - --destination=$(params.imageName):$(params.tag) - --skip-tls-verify - --verbosity=info diff --git a/tasks/git-clone-checkout/task.yaml b/tasks/git-clone-checkout/task.yaml index 8d83b91..f00bc29 100644 --- a/tasks/git-clone-checkout/task.yaml +++ b/tasks/git-clone-checkout/task.yaml @@ -9,15 +9,10 @@ spec: The commit SHA, committer date, and fetched URL are exposed as Task results. params: - - name: home + - name: context type: string default: "" - description: home directory - - - name: workshop - type: string - default: "" - description: workshop inside the `shared` Workspace to clone the repo into. + description: context directory - name: url type: string @@ -91,7 +86,7 @@ spec: description: The image providing the git-init binary that this Task runs. workspaces: - - name: shared + - name: base description: The workspace where the repository will be cloned. results: @@ -107,9 +102,9 @@ spec: image: $(params.gitInitImage) env: - name: HOME - value: /workspace/shared/$(params.home) + value: /workspace/base/$(params.context)/home - name: SSL_CERT_FILE - value: /workspace/shared/$(params.home)/cert/$(params.crtFileName)" + value: /workspace/base/$(params.context)/home/cert/$(params.crtFileName)" - name: HTTP_PROXY value: $(params.httpProxy) - name: HTTPS_PROXY @@ -125,9 +120,9 @@ spec: git config --global http.sslVerify false fi - cd /workspace/shared + cd /workspace/base - CLONE_DIR="$(params.workshop)" + CLONE_DIR="$(params.source)" if [ -z "$CLONE_DIR" ]; then CLONE_DIR="." fi diff --git a/tasks/git-gitops-sync/task.yaml b/tasks/git-gitops-sync/task.yaml index 257d48b..fe832dd 100644 --- a/tasks/git-gitops-sync/task.yaml +++ b/tasks/git-gitops-sync/task.yaml @@ -14,10 +14,10 @@ spec: to the corresponding GitOps repository derived from the application source repo. params: - - name: home + - name: context type: string default: "" - description: home directory + description: context directory - name: repositoryUrl type: string @@ -42,7 +42,7 @@ spec: description: Commit message workspaces: - - name: shared + - name: base steps: - name: update-and-push @@ -50,7 +50,7 @@ spec: workingDir: /workspace env: - name: HOME - value: /workspace/shared/$(params.home) + value: /workspace/base/$(params.context)/home script: | #!/bin/sh set -e @@ -73,8 +73,6 @@ spec: echo "๐Ÿ›  Updating image.tag in $VALUES_PATH to $TAG" yq e ".image.tag = \"$TAG\"" -i "$VALUES_PATH" - git config user.name "tekton-ci" - git config user.email "ci@example.com" git add "$VALUES_PATH" git commit -m "$(params.commitMessage)" || echo "No changes to commit." git push origin "$BRANCH" diff --git a/tasks/nodejs-nx-analysis/task.yaml b/tasks/nodejs-nx-analysis/task.yaml index b674e5e..e5fe9c8 100644 --- a/tasks/nodejs-nx-analysis/task.yaml +++ b/tasks/nodejs-nx-analysis/task.yaml @@ -4,14 +4,9 @@ metadata: name: nx-nodejs-analysis spec: params: - - name: home + - name: context type: string - description: home directory - default: "" - - - name: workshop - type: string - description: workshop within the repo where the source code is located + description: context directory default: "" - name: targetProject @@ -24,7 +19,7 @@ spec: description: Node.js image (e.g., node:18-slim) workspaces: - - name: shared + - name: base description: Git-cloned source code with Nx monorepo results: @@ -36,10 +31,10 @@ spec: steps: - name: lint-and-test image: $(params.nodejsImageName) - workingDir: /workspace/shared/$(params.workshop) + workingDir: /workspace/base/$(params.context)/source env: - name: HOME - value: /workspace/shared/$(params.home) + value: /workspace/base/$(params.context)/home script: | #!/usr/bin/env bash set -e diff --git a/tasks/nodejs-nx-version/task.yaml b/tasks/nodejs-nx-version/task.yaml index e1cbafb..bc96ba3 100644 --- a/tasks/nodejs-nx-version/task.yaml +++ b/tasks/nodejs-nx-version/task.yaml @@ -4,13 +4,9 @@ metadata: name: nx-nodejs-version spec: params: - - name: home + - name: context type: string - description: home directory - default: "" - - name: workshop - type: string - description: workshop within the repo where the source code is located + description: context directory default: "" - name: ref @@ -21,7 +17,7 @@ spec: default: "node:slim" description: Node.js image (e.g., node:23-slim) workspaces: - - name: shared + - name: base description: Git-cloned source code results: - name: version @@ -29,10 +25,10 @@ spec: steps: - name: verify-tag-version image: $(params.nodejsImageName) - workingDir: /workspace/shared/$(params.workshop) + workingDir: /workspace/base/$(params.context)/source env: - name: HOME - value: /workspace/shared/$(params.home) + value: /workspace/base/$(params.context)/home script: | #!/usr/bin/env bash set -e diff --git a/tasks/pybuild/task.yaml b/tasks/pybuild/task.yaml index 79cab64..7d9f73c 100644 --- a/tasks/pybuild/task.yaml +++ b/tasks/pybuild/task.yaml @@ -4,23 +4,18 @@ metadata: name: pybuild spec: params: - - name: home + - name: context type: string default: "" description: home directory - - name: workshop - type: string - default: "" - description: workshop within the repo where the source code is located - - name: pythonImageName type: string default: "python:3.11-slim" description: Python version to use workspaces: - - name: shared + - name: base description: Workspace containing the cloned Git repository results: @@ -30,10 +25,10 @@ spec: steps: - name: build-package image: $(params.pythonImageName) - workingDir: /workspace/shared/$(params.workshop) + workingDir: /workspace/base/$(params.context)/source env: - name: HOME - value: /workspace/shared/$(params.home) + value: /workspace/base/$(params.context)/home script: | #!/usr/bin/env bash set -e @@ -67,7 +62,7 @@ spec: fi echo "๐Ÿ“‚ Checking built artifacts..." - BUILD_PATH="/workspace/shared/$(params.workshop)/dist" + BUILD_PATH="/workspace/base/$(params.workshop)/dist" echo -n "$BUILD_PATH" > /tekton/results/build-artifact-path if [ -d "$BUILD_PATH" ] && [ -n "$(ls -A "$BUILD_PATH")" ]; then diff --git a/tasks/pylint/task.yaml b/tasks/pylint/task.yaml index 5041f5c..e891aa4 100644 --- a/tasks/pylint/task.yaml +++ b/tasks/pylint/task.yaml @@ -4,14 +4,9 @@ metadata: name: pylint spec: params: - - name: home + - name: context type: string - description: home directory - default: "" - - - name: workshop - type: string - description: workshop within the repo where the shared code is located + description: context directory default: "" - name: pythonImageName @@ -36,16 +31,16 @@ spec: description: Exit code returned by pylint (0=clean, non-zero=issues) workspaces: - - name: shared + - name: base description: Workspace containing the cloned Git repository steps: - name: run-pylint image: $(params.pythonImageName) - workingDir: /workspace/shared/$(params.workshop) + workingDir: /workspace/base/$(params.context)/source env: - name: HOME - value: /workspace/shared/$(params.home) + value: /workspace/base/$(params.context)/home script: | #!/usr/bin/env bash set -e @@ -70,7 +65,7 @@ spec: echo "๐Ÿงช Running Pylint (JSON report)..." set +e - REPORT_FILE="/workspace/shared/pylint-report.json" + REPORT_FILE="/workspace/base/pylint-report.json" if [ -f pyproject.toml ]; then poetry run pylint $(params.pylint-args) --output-format=json . > "$REPORT_FILE" diff --git a/tasks/pytest/task.yaml b/tasks/pytest/task.yaml index 20e7400..d22cea5 100644 --- a/tasks/pytest/task.yaml +++ b/tasks/pytest/task.yaml @@ -4,14 +4,9 @@ metadata: name: pytest spec: params: - - name: home + - name: context type: string - description: home directory - default: "" - - - name: workshop - type: string - description: workshop within the workspace where the tests are located + description: context directory default: "" - name: pythonImageName @@ -20,16 +15,16 @@ spec: default: "python:3.11-slim" workspaces: - - name: shared + - name: base description: Workspace containing the cloned Git repository from git-clone-checkout steps: - name: install-dependencies image: $(params.pythonImageName) - workingDir: /workspace/shared/$(params.workshop) + workingDir: /workspace/base/$(params.context)/source env: - name: HOME - value: /workspace/shared/$(params.home) + value: /workspace/base/$(params.context)/home script: | #!/usr/bin/env bash set -e @@ -56,17 +51,17 @@ spec: echo "๐Ÿงช Running tests..." set +e if [ -f pyproject.toml ]; then - poetry run pytest --verbose --junitxml=/workspace/shared/pytest-results.xml + poetry run pytest --verbose --junitxml=/workspace/base/pytest-results.xml else - pytest --verbose --junitxml=/workspace/shared/pytest-results.xml + pytest --verbose --junitxml=/workspace/base/pytest-results.xml fi TEST_EXIT_CODE=$? set -e echo "๐Ÿ“„ Checking test results..." - if [ -f /workspace/shared/pytest-results.xml ]; then + if [ -f /workspace/base/pytest-results.xml ]; then echo "Test results:" - cat /workspace/shared/pytest-results.xml + cat /workspace/base/pytest-results.xml else echo "โŒ No test results found" exit 1 diff --git a/tasks/pyversion/task.yaml b/tasks/pyversion/task.yaml index 74746fe..6def176 100644 --- a/tasks/pyversion/task.yaml +++ b/tasks/pyversion/task.yaml @@ -4,14 +4,9 @@ metadata: name: pyversion spec: params: - - name: home + - name: context type: string - description: home directory - default: "" - - - name: workshop - type: string - description: workshop within the repo where the source code is located + description: context directory default: "" - name: ref @@ -24,7 +19,7 @@ spec: default: "python:3.11-slim" workspaces: - - name: shared + - name: base description: shared code workspace (includes pyproject.toml) results: @@ -34,7 +29,7 @@ spec: steps: - name: verify-tag image: $(params.pythonImageName) - workingDir: /workspace/shared/$(params.workshop) + workingDir: /workspace/base/$(params.context)/source script: | #!/usr/bin/env bash set -e diff --git a/tasks/secret-home/task.yaml b/tasks/secret-home/task.yaml index e776d9c..cc4425d 100644 --- a/tasks/secret-home/task.yaml +++ b/tasks/secret-home/task.yaml @@ -4,14 +4,9 @@ metadata: name: secret-home spec: params: - - name: home + - name: context type: string - description: home directory - default: "" - - - name: workshop - type: string - description: workshop directory + description: context directory default: "" - name: keys @@ -20,7 +15,7 @@ spec: Comma-separated keys (e.g. ".gitconfig,.git-credentials") workspaces: - - name: shared + - name: base description: Workspace containing the cloned Git repository - name: credentials description: Secret data from workspace @@ -28,10 +23,10 @@ spec: steps: - name: extract image: python:3.11-slim - workingDir: /workspace/shared/$(params.workshop) + workingDir: /workspace/base/$(params.context)/source env: - name: HOME - value: /workspace/shared/$(params.home) + value: /workspace/base/$(params.context)/home script: | #!/usr/bin/env bash set -e diff --git a/tasks/sonarqube-analysis/taks.yaml b/tasks/sonarqube-analysis/taks.yaml index 3a70c10..64cec4c 100644 --- a/tasks/sonarqube-analysis/taks.yaml +++ b/tasks/sonarqube-analysis/taks.yaml @@ -4,14 +4,10 @@ metadata: name: sonarqube-analysis spec: params: - - name: home + - name: context type: string default: "" - description: home directory - - name: workshop - type: string - default: "" - description: workshop within workspace containing the source (if any) + description: context directory - name: sonarHostUrl type: string @@ -23,7 +19,7 @@ spec: description: SonarQube project key workspaces: - - name: shared + - name: base description: Workspace with shared code (e.g. from git-clone) - name: sonar-auth @@ -33,7 +29,7 @@ spec: steps: - name: sonar-scan image: sonarsource/sonar-scanner-cli:5 - workingDir: /workspace/shared/$(params.workshop) + workingDir: /workspace/base/$(params.context)/source script: | #!/bin/sh set -e