Debug Jenkins
This commit is contained in:
parent
01fd623189
commit
9a8f8b770b
1 changed files with 31 additions and 49 deletions
80
Jenkinsfile
vendored
80
Jenkinsfile
vendored
|
|
@ -1,55 +1,37 @@
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
REGISTRY = 'codeberg.org/lvl0/incr'
|
REGISTRY = 'codeberg.org'
|
||||||
IMAGE_TAG = "${env.GIT_TAG_NAME ?: 'latest'}"
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
triggers {
|
stage('Build Docker Image') {
|
||||||
pollSCM('H/5 * * * *') // Replace with webhook later
|
steps {
|
||||||
|
echo "⚙️ Building Docker image: ${IMAGE_NAME}:${GIT_TAG}"
|
||||||
|
sh "docker build -f docker/Dockerfile -t ${IMAGE_NAME}:${GIT_TAG} ."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stage('Push to Registry') {
|
||||||
stage('Check Tag') {
|
steps {
|
||||||
when {
|
echo "📤 Pushing Docker image: ${IMAGE_NAME}:${GIT_TAG}"
|
||||||
expression {
|
withCredentials([usernamePassword(credentialsId: "${DOCKER_CREDENTIALS_ID}", usernam]()
|
||||||
return env.GIT_TAG_NAME != null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
echo "🕵️ Detected tag: ${env.GIT_TAG_NAME}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Build Docker Image') {
|
|
||||||
when {
|
|
||||||
expression {
|
|
||||||
return env.GIT_TAG_NAME != null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
sh """
|
|
||||||
echo "⚙️ Building Docker image for ${IMAGE_TAG}"
|
|
||||||
docker build -f docker/Dockerfile -t ${REGISTRY}:${IMAGE_TAG} .
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Push to Registry') {
|
|
||||||
when {
|
|
||||||
expression {
|
|
||||||
return env.GIT_TAG_NAME != null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
withCredentials([usernamePassword(credentialsId: 'codeberg-registry', usernameVariable: 'REGISTRY_USER', passwordVariable: 'REGISTRY_PASS')]) {
|
|
||||||
sh """
|
|
||||||
echo "$REGISTRY_PASS" | docker login ${REGISTRY} -u "$REGISTRY_USER" --password-stdin
|
|
||||||
docker push ${REGISTRY}:${IMAGE_TAG}
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue