This commit is contained in:
병준 박 2025-04-16 00:50:02 +00:00
parent d91d03111f
commit 62c8f80ed0
3 changed files with 74 additions and 60 deletions

View File

@ -35,15 +35,15 @@ spec:
workspaces:
- name: shared
description: Source code workspace
- name: docker-dot-credentials
description: Workspace containing config.json (as Secret)
# - name: docker-dot-credentials
# description: Workspace containing config.json (as Secret)
results:
- name: imageUrl
description: Final pushed image URL with tag (e.g. registry/app:v0.2.0)
steps:
- name: prepare-docker-auth
- name: prepare-docker
image: alpine:3.21.3
workingDir: /workspace/shared/$(params.workshop)
env:
@ -54,9 +54,9 @@ spec:
#!/bin/sh
set -e
echo "🔐 Copying docker .dockerconfigjson to /tekton/home/.docker"
mkdir -p /tekton/home/.docker
cp /workspace/docker-dot-credentials/.dockerconfigjson /tekton/home/.docker/config.json
# echo "🔐 Copying docker .dockerconfigjson to /tekton/home/.docker"
# mkdir -p /tekton/home/.docker
# cp /workspace/docker-dot-credentials/.dockerconfigjson /tekton/home/.docker/config.json
IMAGE="$(params.imageName):$(params.tag)"
echo "📦 Using image: $IMAGE"
@ -66,11 +66,10 @@ spec:
image: gcr.io/kaniko-project/executor:v1.23.2
workingDir: $(workspaces.shared.path)/$(params.workshop)
env:
- name: DOCKER_CONFIG
value: /tekton/home/.docker
- name: HOME
value: /workspace/shared/$(params.home)
- name: DOCKER_CONFIG
value: $HOME/.dockerconfigjson
command:
- /kaniko/executor
args:

View File

@ -45,6 +45,11 @@ spec:
default: "ca-bundle.crt"
description: file name of mounted crt using ssl-ca-directory workspace.
- name: home
type: string
default: ""
description: home directory
- name: workshop
type: string
default: ""
@ -85,30 +90,30 @@ spec:
default: "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.40.2"
description: The image providing the git-init binary that this Task runs.
- name: userHome
type: string
default: "/home/git"
description: Absolute path to the user's home directory.
# - name: userHome
# type: string
# default: "/home/git"
# description: Absolute path to the user's home directory.
workspaces:
- name: shared
description: The workspace where the repository will be cloned.
- name: ssh-directory
optional: true
description: |
A .ssh directory with private key, known_hosts, config, etc.
Copied to the user's home before git commands are executed.
# - name: ssh-directory
# optional: true
# description: |
# A .ssh directory with private key, known_hosts, config, etc.
# Copied to the user's home before git commands are executed.
- name: basic-auth
optional: true
description: |
A Workspace containing a .gitconfig and .git-credentials file.
# - name: basic-auth
# optional: true
# description: |
# A Workspace containing a .gitconfig and .git-credentials file.
- name: ssl-ca-directory
optional: true
description: |
A workspace containing CA certificates, used by Git for SSL verification.
# - name: ssl-ca-directory
# optional: true
# description: |
# A workspace containing CA certificates, used by Git for SSL verification.
results:
@ -123,8 +128,10 @@ spec:
- name: clone
image: $(params.gitInitImage)
env:
# - name: HOME
# value: $(params.userHome)
- name: HOME
value: $(params.userHome)
value: /workspace/shared/$(params.home)
- name: SSL_CERT_FILE
value: "/workspace/ssl-ca-directory/$(params.crtFileName)"
- name: HTTP_PROXY
@ -137,19 +144,19 @@ spec:
#!/bin/sh
set -eu
echo "[INFO] Preparing home and auth setup..."
mkdir -p $(params.userHome)/.ssh
# echo "[INFO] Preparing home and auth setup..."
# mkdir -p $(params.userHome)/.ssh
if [ -d "/workspace/ssh-directory" ]; then
cp -R /workspace/ssh-directory/* $(params.userHome)/.ssh/
chmod 700 $(params.userHome)/.ssh
chmod 600 $(params.userHome)/.ssh/*
fi
# if [ -d "/workspace/ssh-directory" ]; then
# cp -R /workspace/ssh-directory/* $(params.userHome)/.ssh/
# chmod 700 $(params.userHome)/.ssh
# chmod 600 $(params.userHome)/.ssh/*
# fi
if [ -d "/workspace/basic-auth" ]; then
cp /workspace/basic-auth/.gitconfig $(params.userHome)/.gitconfig || true
cp /workspace/basic-auth/.git-credentials $(params.userHome)/.git-credentials || true
fi
# if [ -d "/workspace/basic-auth" ]; then
# cp /workspace/basic-auth/.gitconfig $(params.userHome)/.gitconfig || true
# cp /workspace/basic-auth/.git-credentials $(params.userHome)/.git-credentials || true
# fi
if [ "$(params.sslVerify)" = "false" ]; then
echo "[INFO] Disabling SSL verification"

View File

@ -36,40 +36,48 @@ spec:
default: "chore(gitops): update image tag"
description: Commit message
- name: home
type: string
default: ""
description: home directory
workspaces:
- name: ssh-directory
optional: true
description: SSH credentials (private key, known_hosts)
# - name: ssh-directory
# optional: true
# description: SSH credentials (private key, known_hosts)
- name: basic-auth
optional: true
description: .gitconfig and .git-credentials
# - name: basic-auth
# optional: true
# description: .gitconfig and .git-credentials
- name: ssl-ca-directory
optional: true
description: Custom CA certificates (optional)
# - name: ssl-ca-directory
# optional: true
# description: Custom CA certificates (optional)
steps:
- name: update-and-push
image: alpine:3.19
workingDir: /workspace
env:
- name: HOME
value: /workspace/shared/$(params.home)
script: |
#!/bin/sh
set -e
echo "🔐 Preparing Git authentication..."
mkdir -p /root/.ssh
if [ -d /workspace/ssh-directory ]; then
cp -R /workspace/ssh-directory/* /root/.ssh/
chmod 700 /root/.ssh
fi
if [ -d /workspace/basic-auth ]; then
cp /workspace/basic-auth/.gitconfig /root/.gitconfig || true
cp /workspace/basic-auth/.git-credentials /root/.git-credentials || true
fi
if [ -d /workspace/ssl-ca-directory ]; then
export GIT_SSL_CAINFO="/workspace/ssl-ca-directory/ca.crt"
fi
# echo "🔐 Preparing Git authentication..."
# mkdir -p /root/.ssh
# if [ -d /workspace/ssh-directory ]; then
# cp -R /workspace/ssh-directory/* /root/.ssh/
# chmod 700 /root/.ssh
# fi
# if [ -d /workspace/basic-auth ]; then
# cp /workspace/basic-auth/.gitconfig /root/.gitconfig || true
# cp /workspace/basic-auth/.git-credentials /root/.git-credentials || true
# fi
# if [ -d /workspace/ssl-ca-directory ]; then
# export GIT_SSL_CAINFO="/workspace/ssl-ca-directory/ca.crt"
# fi
echo "📦 Installing Git + yq..."
apk add --no-cache git yq openssh