init
This commit is contained in:
parent
1d6ba5b419
commit
d696e5d8b5
40
tasks/after-pipeline/task.yaml
Normal file
40
tasks/after-pipeline/task.yaml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
apiVersion: tekton.dev/v1
|
||||||
|
kind: Task
|
||||||
|
metadata:
|
||||||
|
name: after-pipeline
|
||||||
|
spec:
|
||||||
|
params:
|
||||||
|
- name: persistence
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
volumeName:
|
||||||
|
type: string
|
||||||
|
namespace:
|
||||||
|
type: string
|
||||||
|
default:
|
||||||
|
volumeName: ""
|
||||||
|
namespace: ""
|
||||||
|
|
||||||
|
results:
|
||||||
|
- name: pvcName
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
description: Name of the PVC to delete if it exists
|
||||||
|
steps:
|
||||||
|
- name: delete-pvc-if-exists
|
||||||
|
image: bitnami/kubectl:latest
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ -n "$(params.persistence.volumeName)" ]; then
|
||||||
|
if kubectl get pvc $(params.persistence.volumeName) -n $(params.persistence.namespace) >/dev/null 2>&1; then
|
||||||
|
echo "PVC $(params.persistence.volumeName) exists, deleting..."
|
||||||
|
kubectl delete pvc $(params.persistence.volumeName) -n $(params.persistence.namespace)
|
||||||
|
echo "PVC $(params.persistence.volumeName) deleted."
|
||||||
|
else
|
||||||
|
echo "PVC $(params.persistence.volumeName) does not exist, skipping deletion."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "No pvcName provided, nothing to delete."
|
||||||
|
fi
|
||||||
|
|
61
tasks/before-pipeline/task.yaml
Normal file
61
tasks/before-pipeline/task.yaml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
apiVersion: tekton.dev/v1
|
||||||
|
kind: Task
|
||||||
|
metadata:
|
||||||
|
name: before-pipeline
|
||||||
|
spec:
|
||||||
|
params:
|
||||||
|
- name: persistence
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
enabled:
|
||||||
|
type: boolean
|
||||||
|
volumeName:
|
||||||
|
type: string
|
||||||
|
namespace:
|
||||||
|
type: string
|
||||||
|
storageClass:
|
||||||
|
type: string
|
||||||
|
accessModes:
|
||||||
|
type: array
|
||||||
|
size:
|
||||||
|
type: string
|
||||||
|
default:
|
||||||
|
enabled: false
|
||||||
|
volumeName: "data"
|
||||||
|
namespace: "default"
|
||||||
|
storageClass: ""
|
||||||
|
accessModes:
|
||||||
|
- "ReadWriteOnce"
|
||||||
|
size: "1Gi"
|
||||||
|
results:
|
||||||
|
- name: pvcName
|
||||||
|
description: Name of the created PVC (if enabled)
|
||||||
|
steps:
|
||||||
|
- name: create-pvc-if-enabled
|
||||||
|
image: bitnami/kubectl:latest
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ "$(params.persistence.enabled)" == "true" ]; then
|
||||||
|
pvcName="$(params.persistence.volumeName)-$(context.taskRun.uid)"
|
||||||
|
cat <<EOF | kubectl apply -f -
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: $pvcName
|
||||||
|
namespace: $(params.persistence.namespace)
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
$(for mode in $(params.persistence.accessModes); do echo " - $mode"; done)
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: $(params.persistence.size)
|
||||||
|
storageClassName: $(params.persistence.storageClass)
|
||||||
|
EOF
|
||||||
|
echo "PVC $pvcName created."
|
||||||
|
echo -n "$pvcName" > /tekton/results/pvcName
|
||||||
|
else
|
||||||
|
echo "Persistence disabled, no PVC created."
|
||||||
|
echo -n "" > /tekton/results/pvcName
|
||||||
|
fi
|
||||||
|
|
@ -24,9 +24,11 @@ spec:
|
|||||||
workingDir: /workspace/source
|
workingDir: /workspace/source
|
||||||
script: |
|
script: |
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [ -n "$(params.subdirectory)" ]; then
|
if [ -n "$(params.subdirectory)" ]; then
|
||||||
cd $(params.subdirectory)
|
cd $(params.subdirectory)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
# Poetry가 있는 경우 설치 및 의존성 처리
|
# Poetry가 있는 경우 설치 및 의존성 처리
|
||||||
if [ -f pyproject.toml ]; then
|
if [ -f pyproject.toml ]; then
|
||||||
@ -43,14 +45,17 @@ spec:
|
|||||||
echo "Error: No valid build configuration found (pyproject.toml or setup.py required)"
|
echo "Error: No valid build configuration found (pyproject.toml or setup.py required)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: build-package
|
- name: build-package
|
||||||
image: python:$(params.python-version)-slim
|
image: python:$(params.python-version)-slim
|
||||||
workingDir: /workspace/source
|
workingDir: /workspace/source
|
||||||
script: |
|
script: |
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [ -n "$(params.subdirectory)" ]; then
|
if [ -n "$(params.subdirectory)" ]; then
|
||||||
cd $(params.subdirectory)
|
cd $(params.subdirectory)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Poetry가 사용된 경우
|
# Poetry가 사용된 경우
|
||||||
if [ -f pyproject.toml ]; then
|
if [ -f pyproject.toml ]; then
|
||||||
poetry build
|
poetry build
|
||||||
@ -65,6 +70,7 @@ spec:
|
|||||||
echo "Error: No build tool available"
|
echo "Error: No build tool available"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 빌드 결과 경로를 결과로 저장
|
# 빌드 결과 경로를 결과로 저장
|
||||||
echo -n "/workspace/source/$(params.subdirectory)/dist" > /tekton/results/build-artifact-path
|
echo -n "/workspace/source/$(params.subdirectory)/dist" > /tekton/results/build-artifact-path
|
||||||
- name: verify-build
|
- name: verify-build
|
||||||
@ -72,6 +78,7 @@ spec:
|
|||||||
workingDir: /workspace/source
|
workingDir: /workspace/source
|
||||||
script: |
|
script: |
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
DIST_PATH=$(cat /tekton/results/build-artifact-path)
|
DIST_PATH=$(cat /tekton/results/build-artifact-path)
|
||||||
if [ -d "$DIST_PATH" ] && [ -n "$(ls -A $DIST_PATH)" ]; then
|
if [ -d "$DIST_PATH" ] && [ -n "$(ls -A $DIST_PATH)" ]; then
|
||||||
echo "Build artifacts successfully created in $DIST_PATH:"
|
echo "Build artifacts successfully created in $DIST_PATH:"
|
||||||
|
@ -25,10 +25,13 @@ spec:
|
|||||||
workingDir: /workspace/source
|
workingDir: /workspace/source
|
||||||
script: |
|
script: |
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [ -n "$(params.subdirectory)" ]; then
|
if [ -n "$(params.subdirectory)" ]; then
|
||||||
cd $(params.subdirectory)
|
cd $(params.subdirectory)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
|
|
||||||
# Poetry가 있는 경우 설치 및 의존성 처리
|
# Poetry가 있는 경우 설치 및 의존성 처리
|
||||||
if [ -f pyproject.toml ]; then
|
if [ -f pyproject.toml ]; then
|
||||||
echo "Detected Poetry project (pyproject.toml found)"
|
echo "Detected Poetry project (pyproject.toml found)"
|
||||||
@ -45,14 +48,17 @@ spec:
|
|||||||
echo "No dependency file found, installing pylint only"
|
echo "No dependency file found, installing pylint only"
|
||||||
pip install pylint
|
pip install pylint
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: run-lint
|
- name: run-lint
|
||||||
image: python:$(params.python-version)-slim
|
image: python:$(params.python-version)-slim
|
||||||
workingDir: /workspace/source
|
workingDir: /workspace/source
|
||||||
script: |
|
script: |
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [ -n "$(params.subdirectory)" ]; then
|
if [ -n "$(params.subdirectory)" ]; then
|
||||||
cd $(params.subdirectory)
|
cd $(params.subdirectory)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Poetry가 사용된 경우 가상환경에서 실행
|
# Poetry가 사용된 경우 가상환경에서 실행
|
||||||
if [ -f pyproject.toml ]; then
|
if [ -f pyproject.toml ]; then
|
||||||
poetry run pylint $(params.pylint-args) .
|
poetry run pylint $(params.pylint-args) .
|
||||||
@ -60,10 +66,12 @@ spec:
|
|||||||
pylint $(params.pylint-args) .
|
pylint $(params.pylint-args) .
|
||||||
fi
|
fi
|
||||||
onError: continue # 린트 실패 시에도 파이프라인을 중단하지 않음 (선택적)
|
onError: continue # 린트 실패 시에도 파이프라인을 중단하지 않음 (선택적)
|
||||||
|
|
||||||
- name: check-results
|
- name: check-results
|
||||||
image: ubuntu
|
image: ubuntu
|
||||||
workingDir: /workspace/source
|
workingDir: /workspace/source
|
||||||
script: |
|
script: |
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
echo "Pylint execution completed."
|
echo "Pylint execution completed."
|
||||||
# Pylint 결과를 별도 파일로 저장하려면 run-lint에서 --output 옵션 추가 필요
|
# Pylint 결과를 별도 파일로 저장하려면 run-lint에서 --output 옵션 추가 필요
|
||||||
|
@ -29,6 +29,7 @@ spec:
|
|||||||
image: python:$(params.python-version)-slim # python-version을 고정하거나 params로 받을 수 있음
|
image: python:$(params.python-version)-slim # python-version을 고정하거나 params로 받을 수 있음
|
||||||
script: |
|
script: |
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
pip install twine
|
pip install twine
|
||||||
twine upload \
|
twine upload \
|
||||||
--repository-url "$(params.pypi-repository-url)" \
|
--repository-url "$(params.pypi-repository-url)" \
|
||||||
|
@ -16,30 +16,19 @@ spec:
|
|||||||
- name: source
|
- name: source
|
||||||
description: Workspace containing the cloned Git repository from git-clone-checkout
|
description: Workspace containing the cloned Git repository from git-clone-checkout
|
||||||
steps:
|
steps:
|
||||||
# - name: debug-workspace
|
|
||||||
# image: ubuntu
|
|
||||||
# workingDir: /workspace/source
|
|
||||||
# script: |
|
|
||||||
# #!/usr/bin/env bash
|
|
||||||
# if [ -n "$(params.subdirectory)" ]; then
|
|
||||||
# if [ -d "$(params.subdirectory)" ]; then
|
|
||||||
# echo "Subdirectory $(params.subdirectory) exists:"
|
|
||||||
# ls -la $(params.subdirectory)
|
|
||||||
# else
|
|
||||||
# echo "Subdirectory $(params.subdirectory) not found!"
|
|
||||||
# exit 1
|
|
||||||
# fi
|
|
||||||
# fi
|
|
||||||
- name: install-dependencies
|
- name: install-dependencies
|
||||||
image: python:$(params.python-version)-slim
|
image: python:$(params.python-version)-slim
|
||||||
workingDir: /workspace/source
|
workingDir: /workspace/source
|
||||||
script: |
|
script: |
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [ -n "$(params.subdirectory)" ]; then
|
if [ -n "$(params.subdirectory)" ]; then
|
||||||
cd $(params.subdirectory)
|
cd $(params.subdirectory)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
pip install pytest
|
pip install pytest
|
||||||
|
|
||||||
if [ -f pyproject.toml ]; then
|
if [ -f pyproject.toml ]; then
|
||||||
pip install poetry
|
pip install poetry
|
||||||
poetry config virtualenvs.in-project true
|
poetry config virtualenvs.in-project true
|
||||||
@ -48,25 +37,30 @@ spec:
|
|||||||
elif [ -f requirements.txt ]; then
|
elif [ -f requirements.txt ]; then
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: run-tests
|
- name: run-tests
|
||||||
image: python:$(params.python-version)-slim
|
image: python:$(params.python-version)-slim
|
||||||
workingDir: /workspace/source
|
workingDir: /workspace/source
|
||||||
script: |
|
script: |
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [ -n "$(params.subdirectory)" ]; then
|
if [ -n "$(params.subdirectory)" ]; then
|
||||||
cd $(params.subdirectory)
|
cd $(params.subdirectory)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f pyproject.toml ]; then
|
if [ -f pyproject.toml ]; then
|
||||||
poetry run pytest --verbose --junitxml=/workspace/source/pytest-results.xml
|
poetry run pytest --verbose --junitxml=/workspace/source/pytest-results.xml
|
||||||
else
|
else
|
||||||
pytest --verbose --junitxml=/workspace/source/pytest-results.xml
|
pytest --verbose --junitxml=/workspace/source/pytest-results.xml
|
||||||
fi
|
fi
|
||||||
onError: continue
|
onError: continue
|
||||||
|
|
||||||
- name: check-results
|
- name: check-results
|
||||||
image: ubuntu
|
image: ubuntu
|
||||||
workingDir: /workspace/source
|
workingDir: /workspace/source
|
||||||
script: |
|
script: |
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [ -f pytest-results.xml ]; then
|
if [ -f pytest-results.xml ]; then
|
||||||
echo "Test results generated: pytest-results.xml"
|
echo "Test results generated: pytest-results.xml"
|
||||||
cat pytest-results.xml
|
cat pytest-results.xml
|
||||||
|
@ -12,5 +12,6 @@ spec:
|
|||||||
image: bitnami/kubectl:latest
|
image: bitnami/kubectl:latest
|
||||||
script: |
|
script: |
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
kubectl delete pvc $(params.pvc-name) -n gitops-ci --ignore-not-found=true
|
kubectl delete pvc $(params.pvc-name) -n gitops-ci --ignore-not-found=true
|
||||||
echo "PVC $(params.pvc-name) deleted."
|
echo "PVC $(params.pvc-name) deleted."
|
Loading…
x
Reference in New Issue
Block a user