incr/Jenkinsfile

38 lines
1.1 KiB
Text
Raw Normal View History

2025-07-13 21:51:56 +02:00
pipeline {
2025-07-13 21:53:58 +02:00
agent any
2025-07-13 21:51:56 +02:00
2025-07-13 21:53:58 +02:00
environment {
REGISTRY = 'codeberg.org'
IMAGE_NAME = "${REGISTRY}/lvl0/incr"
DOCKER_CREDENTIALS_ID = 'codeberg-registry' // Jenkins credential ID
}
2025-07-13 21:51:56 +02:00
2025-07-13 21:53:58 +02:00
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")
}
2025-07-13 21:51:56 +02:00
}
2025-07-13 21:53:58 +02:00
}
}
2025-07-13 21:51:56 +02:00
2025-07-13 21:53:58 +02:00
stage('Build Docker Image') {
steps {
echo "⚙️ Building Docker image: ${IMAGE_NAME}:${GIT_TAG}"
sh "docker build -f docker/Dockerfile -t ${IMAGE_NAME}:${GIT_TAG} ."
}
2025-07-13 21:51:56 +02:00
}
2025-07-13 21:53:58 +02:00
stage('Push to Registry') {
steps {
echo "📤 Pushing Docker image: ${IMAGE_NAME}:${GIT_TAG}"
withCredentials([usernamePassword(credentialsId: "${DOCKER_CREDENTIALS_ID}", usernam]()