diff --git a/cluster/platform/innoventions/harbor-credentials.yaml b/cluster/platform/innoventions/harbor-credentials.yaml index 740ab03..65319e8 100644 --- a/cluster/platform/innoventions/harbor-credentials.yaml +++ b/cluster/platform/innoventions/harbor-credentials.yaml @@ -27,6 +27,16 @@ spec: } } } + config.json: | + { + "auths": { + "the-seas.local.mk-labs.cloud": { + "username": "{{ .tekton_username }}", + "password": "{{ .tekton_password }}", + "auth": "{{ printf "%s:%s" .tekton_username .tekton_password | b64enc }}" + } + } + } data: - secretKey: tekton_username remoteRef: diff --git a/cluster/tekton/pipelineruns/test-app-build.yaml b/cluster/tekton/pipelineruns/test-app-build.yaml new file mode 100644 index 0000000..0f1fa05 --- /dev/null +++ b/cluster/tekton/pipelineruns/test-app-build.yaml @@ -0,0 +1,34 @@ +apiVersion: tekton.dev/v1beta1 +kind: PipelineRun +metadata: + name: test-app-build-005 + namespace: innoventions + labels: + app: test-app + pipeline: container-build + annotations: + description: "Test build of sample application to validate Harbor authentication" +spec: + pipelineRef: + name: container-build + timeout: 30m + params: + - name: git-url + value: https://gitea.mk-labs.cloud/rblundon/homelab.git + - name: git-revision + value: main + - name: image-name + value: the-seas.local.mk-labs.cloud/library/test-app + - name: image-tag + value: v1.0.0 + - name: dockerfile + value: ./test-app.Dockerfile + - name: context + value: ./ + workspaces: + - name: shared-workspace + persistentVolumeClaim: + claimName: tekton-workspace + - name: docker-credentials + secret: + secretName: harbor-credentials diff --git a/cluster/tekton/tasks/git-clone.yaml b/cluster/tekton/tasks/git-clone.yaml index 33ee7c5..00b7f6e 100644 --- a/cluster/tekton/tasks/git-clone.yaml +++ b/cluster/tekton/tasks/git-clone.yaml @@ -72,7 +72,7 @@ spec: - name: gitInitImage description: The image providing the git-init binary that this Task runs. type: string - default: "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.40.2" + default: "alpine/git:2.45.2" - name: userHome description: | Absolute path to the user's home directory. Set this explicitly if you are running the image as a non-root user or have overridden @@ -157,15 +157,41 @@ spec: test -z "${PARAM_HTTPS_PROXY}" || export HTTPS_PROXY="${PARAM_HTTPS_PROXY}" test -z "${PARAM_NO_PROXY}" || export NO_PROXY="${PARAM_NO_PROXY}" - /ko-app/git-init \ - -url="${PARAM_URL}" \ - -revision="${PARAM_REVISION}" \ - -refspec="${PARAM_REFSPEC}" \ - -path="${CHECKOUT_DIR}" \ - -sslVerify="${PARAM_SSL_VERIFY}" \ - -submodules="${PARAM_SUBMODULES}" \ - -depth="${PARAM_DEPTH}" + # Configure git + git config --global http.sslVerify "${PARAM_SSL_VERIFY}" + + # Clone the repository + if [ "${PARAM_DEPTH}" != "0" ]; then + DEPTH_ARG="--depth=${PARAM_DEPTH}" + else + DEPTH_ARG="" + fi + + if [ "${PARAM_SUBDIRECTORY}" != "" ] ; then + CHECKOUT_DIR="${WORKSPACE_OUTPUT_PATH}/${PARAM_SUBDIRECTORY}" + else + CHECKOUT_DIR="${WORKSPACE_OUTPUT_PATH}" + fi + + mkdir -p "${CHECKOUT_DIR}" cd "${CHECKOUT_DIR}" + + # Clone with optional depth + git clone ${DEPTH_ARG} --no-checkout "${PARAM_URL}" . + + # Fetch refspec if provided + if [ -n "${PARAM_REFSPEC}" ]; then + git fetch origin "${PARAM_REFSPEC}" + fi + + # Checkout the specified revision + git checkout "${PARAM_REVISION}" + + # Update submodules if requested + if [ "${PARAM_SUBMODULES}" = "true" ] ; then + git submodule update --init --recursive ${DEPTH_ARG} + fi + RESULT_SHA="$(git rev-parse HEAD)" EXIT_CODE="$?" if [ "${EXIT_CODE}" != 0 ] ; then diff --git a/cluster/tekton/tasks/kaniko-build.yaml b/cluster/tekton/tasks/kaniko-build.yaml index d8888b4..1b18b27 100644 --- a/cluster/tekton/tasks/kaniko-build.yaml +++ b/cluster/tekton/tasks/kaniko-build.yaml @@ -33,7 +33,7 @@ spec: default: [] - name: BUILDER_IMAGE description: The image on which builds will run (default is v1.23.2) - default: gcr.io/kaniko-project/executor:v1.23.2@sha256:7f77bc1c6b96e5da7fdb56fb0dc1c16ba0f7fc8b5d1eeaa75fa5db39ec2f4a4d + default: gcr.io/kaniko-project/executor:v1.23.2 workspaces: - name: source description: Holds the context and Dockerfile