Raplce implicit docker calls with shared library steps

This commit is contained in:
2025-06-04 11:07:29 +02:00
parent 4a8bfc622d
commit 3ccafcf0bb

24
Jenkinsfile vendored
View File

@@ -1,3 +1,5 @@
@Library('example-shared-lib@main') _
pipeline { pipeline {
agent { agent {
label "docker-agent-dsrv02" label "docker-agent-dsrv02"
@@ -54,23 +56,21 @@ pipeline {
stage('Build Docker Image') { stage('Build Docker Image') {
steps { steps {
echo "Building Docker image..." dockerBuild(
sh "docker build -t ${DOCKER_REGISTRY}/${IMAGE_NAME}:${BUILD_ID} -f deployments/docker/Dockerfile deployments/docker/" imageName: "${IMAGE_TAG}",
dockerfile: "deployments/docker/Dockerfile",
context: "deployments/docker"
)
} }
} }
stage('Push Docker Image') { stage('Push Docker Image') {
steps { steps {
withCredentials([usernamePassword( dockerPush(
credentialsId: 'postio-bot-gitea', // <-- Update to your Jenkins credentials ID imageName: "${IMAGE_TAG}",
usernameVariable: 'DOCKER_USER', registry: "${DOCKER_REGISTRY}",
passwordVariable: 'DOCKER_PASS' credentialsId: "postio-bot-gitea"
)]) { )
echo "Logging into Docker registry..."
sh "echo $DOCKER_PASS | docker login ${DOCKER_REGISTRY} -u $DOCKER_USER --password-stdin"
echo "Pushing Docker image..."
sh "docker push ${DOCKER_REGISTRY}/${IMAGE_NAME}:${BUILD_ID}"
}
} }
} }
} }