From 3ccafcf0bbe34ff12e2d2aea30897b7a8655f9dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20W=C3=B3jcik?= Date: Wed, 4 Jun 2025 11:07:29 +0200 Subject: [PATCH] Raplce implicit docker calls with shared library steps --- Jenkinsfile | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 940f3f7..fb9a2be 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,5 @@ +@Library('example-shared-lib@main') _ + pipeline { agent { label "docker-agent-dsrv02" @@ -54,23 +56,21 @@ pipeline { stage('Build Docker Image') { steps { - echo "Building Docker image..." - sh "docker build -t ${DOCKER_REGISTRY}/${IMAGE_NAME}:${BUILD_ID} -f deployments/docker/Dockerfile deployments/docker/" + dockerBuild( + imageName: "${IMAGE_TAG}", + dockerfile: "deployments/docker/Dockerfile", + context: "deployments/docker" + ) } } stage('Push Docker Image') { steps { - withCredentials([usernamePassword( - credentialsId: 'postio-bot-gitea', // <-- Update to your Jenkins credentials ID - usernameVariable: 'DOCKER_USER', - passwordVariable: 'DOCKER_PASS' - )]) { - 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}" - } + dockerPush( + imageName: "${IMAGE_TAG}", + registry: "${DOCKER_REGISTRY}", + credentialsId: "postio-bot-gitea" + ) } } }