pipeline { agent any environment { IMG_NAME = 'firmtracker-server' DOCKER_REPO = 'maciejm0101/firmtracker' } stages { stage('build') { steps { script { sh 'docker build -t ${IMG_NAME} .' sh 'docker tag ${IMG_NAME} ${DOCKER_REPO}:${IMG_NAME}' } } } stage('push') { steps { withCredentials([usernamePassword(credentialsId: 'DockerHub-LG', passwordVariable: 'PSWD', usernameVariable: 'LOGIN')]) { script { sh 'echo ${PSWD} | docker login -u ${LOGIN} --password-stdin' sh 'docker push ${DOCKER_REPO}:${IMG_NAME}' } } } } } }