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" + ) } } }