atuin/Jenkinsfile
Sebastian Hugentobler 1915d9bbff
Some checks are pending
Build Multiarch Container Image / call-reusable-workflow (push) Waiting to run
try git ref
2025-06-04 08:26:33 +02:00

32 lines
1.2 KiB
Groovy

pipeline {
agent { label 'linux-aarch64' }
environment {
GIT_REF = """${sh(
returnStdout: true,
script: 'git describe --tags --exact-match 2>/dev/null || git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD'
).trim()}"""
CONTAINER_REGISTRY = credentials('container_registry')
REPO_NAME = env.GIT_URL.replaceFirst(/^.*\/([^\/]+)\/([^\/]+?)\.git$/, '$1/$2')
}
stages {
stage('Build') {
when { tag "*" }
steps {
sh "printenv"
sh "echo $REPO_NAME"
sh "podman build -t ${CONTAINER_REGISTRY}/${REPO_NAME}:${env.BRANCH_NAME} ."
}
}
stage('Push') {
when { tag "*" }
steps {
withCredentials([usernamePassword(credentialsId: 'dockerhub', usernameVariable: 'REG_USERNAME', passwordVariable: 'REG_PASSWORD')]) {
sh '''
podman login docker.io -u $REG_USERNAME -p $REG_PASSWORD
podman push ${CONTAINER_REGISTRY}/${REPO_NAME}:${GIT_REF}
'''
}
}
}
}
}