init
This commit is contained in:
parent
ad3db6f658
commit
2dbe116301
@ -1,4 +1,4 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: docker-registry
|
||||
@ -39,38 +39,51 @@ spec:
|
||||
description: Final pushed image URL with tag (e.g. registry/app:v0.2.0)
|
||||
|
||||
steps:
|
||||
- name: write-docker-config
|
||||
image: alpine:3.18
|
||||
workingDir: /workspace/source
|
||||
script: |
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ -n "$(params.subdirectory)" ]; then
|
||||
cd "$(params.subdirectory)"
|
||||
fi
|
||||
|
||||
IMAGE="$(params.imageName):$(params.tag)"
|
||||
USERNAME=$(cat /workspace/docker-auth/username)
|
||||
PASSWORD=$(cat /workspace/docker-auth/password)
|
||||
REGISTRY=$(echo "$IMAGE" | cut -d/ -f1)
|
||||
|
||||
echo "🔐 Creating Docker config for $REGISTRY..."
|
||||
mkdir -p /tekton/home/.docker
|
||||
echo "{\"auths\": {\"$REGISTRY\": {\"auth\": \"$(echo -n "$USERNAME:$PASSWORD" | base64)\"}}}" \
|
||||
> /tekton/home/.docker/config.json
|
||||
|
||||
- name: kaniko-build
|
||||
image: gcr.io/kaniko-project/executor:v1.23.2
|
||||
- name: build-and-push
|
||||
image: bash:5
|
||||
workingDir: /workspace/source
|
||||
env:
|
||||
- name: DOCKER_CONFIG
|
||||
value: /tekton/home/.docker
|
||||
args:
|
||||
- --dockerfile=$(params.dockerfile)
|
||||
- --context=$(params.context)
|
||||
- --destination=$(params.imageName):$(params.tag)
|
||||
- --skip-tls-verify
|
||||
- --reproducible
|
||||
- --verbosity=info
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -n "$(params.subdirectory)" ]]; then
|
||||
cd "$(params.subdirectory)"
|
||||
fi
|
||||
|
||||
IMAGE="$(params.imageName):$(params.tag)"
|
||||
echo "📦 Using image: $IMAGE"
|
||||
echo -n "$IMAGE" > /tekton/results/imageUrl
|
||||
|
||||
USERNAME=$(cat /workspace/docker-auth/username)
|
||||
PASSWORD=$(cat /workspace/docker-auth/password)
|
||||
REGISTRY=$(cut -d/ -f1 <<< "$IMAGE")
|
||||
|
||||
echo "🔐 Writing Docker config for $REGISTRY..."
|
||||
mkdir -p "$DOCKER_CONFIG"
|
||||
cat > "$DOCKER_CONFIG/config.json" <<EOF
|
||||
{
|
||||
"auths": {
|
||||
"$REGISTRY": {
|
||||
"auth": "$(echo -n "$USERNAME:$PASSWORD" | base64)"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "📥 Downloading Kaniko executor..."
|
||||
curl -sSL -o /kaniko.tar.gz https://github.com/GoogleContainerTools/kaniko/releases/download/v1.23.2/executor-linux-amd64.tar.gz
|
||||
mkdir -p /kaniko && tar -xzf /kaniko.tar.gz -C /kaniko
|
||||
chmod +x /kaniko/executor
|
||||
|
||||
echo "🚀 Building and pushing image..."
|
||||
/kaniko/executor \
|
||||
--dockerfile="$(params.dockerfile)" \
|
||||
--context="$(params.context)" \
|
||||
--destination="$IMAGE" \
|
||||
--skip-tls-verify \
|
||||
--reproducible \
|
||||
--verbosity=info
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: git-gitops-sync
|
||||
|
@ -1,4 +1,4 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: nx-nodejs-version
|
||||
|
@ -1,4 +1,4 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: pybuild
|
||||
|
@ -1,4 +1,4 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: pylint
|
||||
|
@ -1,4 +1,4 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: pypi
|
||||
|
@ -1,4 +1,4 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: pytest
|
||||
|
@ -1,4 +1,4 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: pyversion
|
||||
|
48
tasks/sonarqube-analysis/taks.yaml
Normal file
48
tasks/sonarqube-analysis/taks.yaml
Normal file
@ -0,0 +1,48 @@
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: sonarqube-analysis
|
||||
spec:
|
||||
params:
|
||||
- name: subdirectory
|
||||
type: string
|
||||
default: ""
|
||||
description: Subdirectory within workspace containing the source (if any)
|
||||
|
||||
- name: sonarHostUrl
|
||||
type: string
|
||||
default: "https://sonarqube.unbox-x.net"
|
||||
description: SonarQube server URL
|
||||
|
||||
- name: projectKey
|
||||
type: string
|
||||
description: SonarQube project key
|
||||
|
||||
workspaces:
|
||||
- name: source
|
||||
description: Workspace with source code (e.g. from git-clone)
|
||||
|
||||
- name: sonar-auth
|
||||
description: |
|
||||
Workspace containing authentication token (file: `token`)
|
||||
|
||||
steps:
|
||||
- name: sonar-scan
|
||||
image: sonarsource/sonar-scanner-cli:5
|
||||
workingDir: /workspace/source
|
||||
script: |
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ -n "$(params.subdirectory)" ]; then
|
||||
cd "$(params.subdirectory)"
|
||||
fi
|
||||
|
||||
SONAR_TOKEN=$(cat /workspace/sonar-auth/token)
|
||||
|
||||
echo "📡 Running SonarQube analysis on project $(params.projectKey)..."
|
||||
|
||||
sonar-scanner \
|
||||
-Dsonar.projectKey=$(params.projectKey) \
|
||||
-Dsonar.host.url=$(params.sonarHostUrl) \
|
||||
-Dsonar.login=$SONAR_TOKEN
|
Loading…
x
Reference in New Issue
Block a user