Jenkins pipeline for Docker Push getting error - Layer Already Exists
I am trying a test project of jenkins
2 VMs Jenkins Master & Slave running in Windows 10 Hyper V each with 4GB, but can allocate dynamically.
Jenkins Pipeline code is given below;
pipeline{
agent{
label “jenkins-agent”
}
tools {
jdk ‘Java17’
maven ‘Maven3’
}
environment {
APP_NAME = “complete-prodcution-e2e-pipeline”
RELEASE = “2.0.0”
DOCKER_USER = “testdocker”
DOCKER_PASS = ‘dockerhub’
IMAGE_NAME = “${DOCKER_USER}” + “/” + “${APP_NAME}”
IMAGE_TAG = “${RELEASE}-${BUILD_NUMBER}”
}
stages{
stage("Cleanup Workspace"){
steps {
cleanWs()
}
}
stage("Checkout from SCM"){
steps {
git branch: 'main', credentialsId: 'github', url: 'https://github.com/testhub/complete-prodcution-e2e-pipeline.git'
}
}
stage("Clean the Application"){
steps {
sh "mvn clean package"
}
}
stage("Test the Application"){
steps {
sh "mvn test"
}
}
stage("Sonarqube Analysis") {
steps {
script {
withSonarQubeEnv(credentialsId: 'jenkins-sonarqube-token') {
sh "mvn sonar:sonar"
}
}
}
}
stage("Quality Gate") {
steps {
script {
waitForQualityGate abortPipeline: false, credentialsId: 'jenkins-sonarqube-token'
}
}
}
stage(“Build & Push Docker Image”) {
steps {
script {
docker.withRegistry(‘’,DOCKER_PASS) {
docker_image = docker.build “${IMAGE_NAME}”
}
docker.withRegistry('',DOCKER_PASS) {
docker_image.push("${IMAGE_TAG}")
docker_image.push('late')
}
}
}
}
}
}
Dockerfile in Github
FROM maven:3.9.0-eclipse-temurin-17 as build
WORKDIR /app
COPY . .
RUN mvn clean install
FROM eclipse-temurin:17.0.6_10-jdk
WORKDIR /app
RUN rm -rf /app/*
COPY --from=build /app/target/demoapp.jar /app/
EXPOSE 8080
CMD [“java”, “-jar”,“demoapp.jar”]
Solutions Tried
Reinstalled the whole system including windows and hyper v
Created new github and docker account - even in first run getting the error
Tried with a different internet connection
Tried most of the google search solutions
Error Screenshot attached.