jenkinsfile
Some checks failed
eCommerce-backend/pipeline/head There was a failure building this commit

This commit is contained in:
2026-02-20 15:57:03 +00:00
parent e5a4bc5890
commit f5d88706f0

29
Jenkinsfile vendored
View File

@@ -7,6 +7,8 @@ pipeline {
IMAGE_NAME = "ecommerce-backend" IMAGE_NAME = "ecommerce-backend"
IMAGE_TAG = "${REGISTRY}/library/${IMAGE_NAME}:${env.BRANCH_NAME}-${env.BUILD_NUMBER}" IMAGE_TAG = "${REGISTRY}/library/${IMAGE_NAME}:${env.BRANCH_NAME}-${env.BUILD_NUMBER}"
NAMESPACE = "ecommerce" NAMESPACE = "ecommerce"
// Explicitly tell the docker wrapper where to find the daemon you just started
BUILDKIT_HOST = "unix:///run/buildkit/buildkitd.sock"
} }
stages { stages {
@@ -19,12 +21,20 @@ pipeline {
stage('Build Image') { stage('Build Image') {
steps { steps {
script { script {
// We call nerdctl directly, bypassing the 'docker' wrapper script. // Check if the socket you just created is actually visible to the Jenkins agent
// This uses the containerd socket that your deployment YAML confirmed is at /run/containerd-pod/containerd.sock sh """
sh "nerdctl --address /run/containerd-pod/containerd.sock build -t ${IMAGE_TAG} ." if [ -S /run/buildkit/buildkitd.sock ]; then
echo "BuildKit socket found! Proceeding with build..."
else
echo "BuildKit socket NOT found at /run/buildkit/buildkitd.sock"
echo "Listing /run to find correct path:"
ls -R /run
exit 1
fi
"""
// Tag it as latest for the local cache as well // Build using the socket
sh "nerdctl --address /run/containerd-pod/containerd.sock tag ${IMAGE_TAG} ${IMAGE_NAME}:latest" sh "docker build -t ${IMAGE_TAG} ."
} }
} }
} }
@@ -43,7 +53,7 @@ pipeline {
stage('Inject to K8s Cache') { stage('Inject to K8s Cache') {
steps { steps {
script { script {
// Force the image into the local containerd store // This is crucial: inject into the k8s namespace
sh "docker save ${IMAGE_TAG} | sudo ctr -n k8s.io images import -" sh "docker save ${IMAGE_TAG} | sudo ctr -n k8s.io images import -"
} }
} }
@@ -63,11 +73,4 @@ pipeline {
} }
} }
} }
post {
always {
// Cleanup to save space on the agent
sh "docker rmi ${IMAGE_TAG} || true"
}
}
} }