// common.libsonnet - Shared configuration { environment: { GIT_SSL_NO_VERIFY: "true" }, cloneStep: { name: "clone", image: "alpine/git", commands: [ "echo '๐Ÿ”„ Cloning repository...'", "git config --global http.sslVerify false", "git config --global user.email 'drone@aipice.local'", "git config --global user.name 'Drone CI'", "git clone https://gitea.aipice.local/AIPICE/auth-service.git . || echo 'Clone failed, but continuing...'", "git checkout $DRONE_COMMIT || echo 'Checkout failed, using default'" ], when: { event: ["push"] } }, versionStep: { name: "read-version", image: "alpine:latest", commands: [ "echo '๐Ÿ“„ Reading version configuration...'", "echo 'Sourcing version.conf...'", ". ./version.conf", "echo \"BASE_VERSION: $BASE_VERSION\"", "echo \"DOCKER_REPO: $DOCKER_REPO\"", "DOCKER_TAG=\"$DOCKER_REPO:$BASE_VERSION.$DRONE_BUILD_NUMBER\"", "echo \"DOCKER_TAG: $DOCKER_TAG\"", "echo 'โœ… Version configuration loaded!'", "echo \"Will build: $DOCKER_TAG\"" ], when: { event: ["push"] } }, testStep: { name: "test", image: "alpine:latest", commands: [ "echo '๐Ÿงช Starting tests...'", "echo 'Repository ${DRONE_REPO}'", "echo 'Branch ${DRONE_BRANCH}'", "echo 'Owner ${DRONE_REPO_OWNER}'", "echo 'Commit ${DRONE_COMMIT_SHA:0:8}'", "echo 'Build ${DRONE_BUILD_NUMBER}'", "echo 'Reading version info...'", ". ./version.conf", "DOCKER_TAG=\"$DOCKER_REPO:$BASE_VERSION.$DRONE_BUILD_NUMBER\"", "echo \"Docker tag will be: $DOCKER_TAG\"", "echo 'Checking Dockerfile:'", "cat Dockerfile || echo 'โŒ Dockerfile not found!'", "echo 'โœ… Pre-build validation passed!'" ], when: { event: ["push"] } }, cleanupStep: { name: "cleanup-build-lock", image: "alpine:latest", commands: [ "echo '๐Ÿงน Ensuring build lock cleanup...'", "apk add --no-cache curl", "curl -LO \"https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl\"", "chmod +x kubectl && mv kubectl /usr/local/bin/", "BUILDAH_POD=$(kubectl get pods -n apps--droneio--prd -l app=buildah-external --field-selector=status.phase=Running -o jsonpath='{.items[0].metadata.name}')", "if [ -n \"$BUILDAH_POD\" ]; then kubectl exec $BUILDAH_POD -n apps--droneio--prd -- rm -f \"/workspace/locks/build-${DRONE_BUILD_NUMBER}.lock\" || echo \"Lock cleanup completed\"; echo \"โœ… Lock cleanup verified\"; else echo \"โš ๏ธ Buildah pod not available for cleanup\"; fi" ], when: { status: ["success", "failure"] } }, trigger: { event: ["push", "pull_request"] } }