incr/Jenkinsfile
2025-07-13 21:53:58 +02:00

37 lines
1.1 KiB
Groovy

pipeline {
agent any
environment {
REGISTRY = 'codeberg.org'
IMAGE_NAME = "${REGISTRY}/lvl0/incr"
DOCKER_CREDENTIALS_ID = 'codeberg-registry' // Jenkins credential ID
}
stages {
stage('Detect Tag') {
steps {
script {
def tag = sh(script: 'git describe --tags --exact-match || true', returnStdout: true).trim()
if (tag) {
env.GIT_TAG = tag
echo "✅ Detected tag: ${tag}"
} else {
echo "⛔ No tag detected — skipping build"
currentBuild.result = 'SUCCESS'
error("Skipping non-tag build")
}
}
}
}
stage('Build Docker Image') {
steps {
echo "⚙️ Building Docker image: ${IMAGE_NAME}:${GIT_TAG}"
sh "docker build -f docker/Dockerfile -t ${IMAGE_NAME}:${GIT_TAG} ."
}
}
stage('Push to Registry') {
steps {
echo "📤 Pushing Docker image: ${IMAGE_NAME}:${GIT_TAG}"
withCredentials([usernamePassword(credentialsId: "${DOCKER_CREDENTIALS_ID}", usernam]()