From 59743758cd2c6feb1160dd42d9366fdc61fc4062 Mon Sep 17 00:00:00 2001 From: Milan Petrovic <5rovicmilan8@gmail.com> Date: Wed, 11 Jun 2025 13:59:20 +0200 Subject: [PATCH] Build stage --- Jenkinsfile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index cafd8e653..86d678983 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,9 +27,19 @@ pipeline { steps { script { def branch = env.BRANCH_NAME - sh """ - echo $BRANCH_NAME - """ + def dockerRepo = (branch == 'main') ? 'main' : 'mr' + def imageTag = "${DOCKER_HUB_USER}/${repo}:${GIT_COMMIT_SHORT}" + + withCredentials([usernamePassword( + credentialsId: DOCKERHUB_CREDES, + usernameVariable: 'DOCKER_USER', + passwordVariable: 'DOCKER_PASS' + )]) { + echo "Logging in to Docker Hub..." + sh "echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin" + echo "Pushing Docker image to ${imageTag}" + sh "docker push ${imageTag}" + } } } }