Here are three scripts for Tekton. It did not find git directory and compile with mvn due to the missing pom.xml. I tried to fix the problems by revising task, pipeline and pipelinerun but it is not fixed. Where am I supposed to revise the script to fix the issue?
I tried to fix the workspace path and used static path to resolve the issue; however, it did not work.
Task:
apiVersion: tekton.dev/v1beta1kind: Taskmetadata: name: maven-buildspec: workspaces: - name: source params: - name: package type: string steps: - name: build image: maven:3.8.6-openjdk-11 script: | #!/bin/sh echo "=== Checking workspace contents ===" ls -lah $(workspaces.source.path) # 저장소폴더로이동 cd $(workspaces.source.path)/tekton-tutorial-greeter # 프로젝트가있는지확인 if [ ! -f "pom.xml" ]; then echo "ERROR: pom.xml not found! Exiting..." exit 1 fi mvn clean package cp target/*.jar $(workspaces.source.path)/$(params.package).jar
Pipeline:
apiVersion: tekton.dev/v1beta1kind: Pipelinemetadata: name: greeter-maven-build-pipelinespec: params: - name: repo-url type: string default: "https://github.com/gitops-cookbook/tekton-tutorial-greeter.git" - name: revision type: string default: "main" - name: image-name type: string default: "greeter-app" workspaces: - name: shared-workspace tasks: - name: fetch-source taskRef: name: git-clone params: - name: url value: "$(params.repo-url)" - name: revision value: "$(params.revision)" workspaces: - name: output workspace: shared-workspace - name: build-and-package taskRef: name: maven-build runAfter: - fetch-source params: - name: package value: "$(params.image-name)" workspaces: - name: source workspace: shared-workspace
pipelinerun:
apiVersion: tekton.dev/v1beta1kind: PipelineRunmetadata: name: greeter-maven-build-runspec: pipelineRef: name: greeter-maven-build-pipeline workspaces: - name: shared-workspace emptyDir: {} params: - name: repo-url value: "https://github.com/gitops-cookbook/tekton-tutorial-greeter.git" - name: revision value: "master" - name: image-name value: "greeter-app"
Log:
task build-and-package has failed: "step-build" exited with code 1[build-and-package : build] === Checking workspace contents ===[build-and-package : build] total 8.0K[build-and-package : build] drwxrwxrwx 2 root root 4.0K Mar 29 07:46 .[build-and-package : build] drwxrwxrwx 3 root root 4.0K Mar 29 07:46 ..[build-and-package : build] /tekton/scripts/script-0-7cbds: 6: cd: can't cd to /workspace/source/tekton-tutorial-greeter[build-and-package : build] ERROR: pom.xml not found! Exiting...failed to get logs for task build-and-package : container step-build has failed : [{"key":"StartedAt","value":"2025-03-29T07:46:57.141Z","type":3}]