Fix tag matching

This commit is contained in:
myrmidex 2025-07-14 21:01:41 +02:00
parent 2fed772e47
commit 53bcce2b98

22
Jenkinsfile vendored
View file

@ -3,12 +3,10 @@ pipeline {
triggers {
GenericTrigger(
causeString: 'Triggered on tag push',
causeString: 'Triggered by push event',
token: 'tag-trigger-secret',
printContributedVariables: true,
printPostContent: true,
regexpFilterExpression: 'ref=refs/tags/.*\nafter=(?!0{40}).*',
regexpFilterText: '$ref\n$after',
genericVariables: [
[key: 'ref', value: '$.ref'],
[key: 'after', value: '$.after']
@ -23,22 +21,30 @@ pipeline {
}
stages {
stage('Tag Check') {
stage('Tag Push Filter') {
steps {
script {
def isTag = sh(script: 'git describe --tags --exact-match || echo "nope"', returnStdout: true).trim()
if (isTag == "nope") {
echo "Not a tag. Skipping build."
if (!env.ref?.startsWith('refs/tags/')) {
echo "Not a tag push (ref = ${env.ref}). Skipping build."
currentBuild.result = 'NOT_BUILT'
return
}
if (env.after == null || env.after ==~ /^0{40}$/) {
echo "After SHA is null or zeroed (after = ${env.after}). Skipping build."
currentBuild.result = 'NOT_BUILT'
return
}
echo "Valid tag push detected: ${env.ref} (${env.after})"
}
}
}
stage('Build & Push Docker Image') {
when {
expression {
return env.GIT_COMMIT && env.GIT_COMMIT != ""
return env.ref?.startsWith('refs/tags/') && env.GIT_COMMIT && env.GIT_COMMIT != ""
}
}
steps {