diff --git a/Dockerfile b/Dockerfile index 15130d4ea..7773e4d0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,10 @@ WORKDIR /app # Define a build argument for the artifact version ARG ARTIFACT_VERSION +ARG ARTIFACT_PATH + # Copy the JAR file into the image dynamically using the provided version -COPY target/spring-petclinic-${ARTIFACT_VERSION}.jar app.jar +COPY ${ARTIFACT_PATH}/petclinic-${ARTIFACT_VERSION}.jar app.jar # Expose port 80 for the application EXPOSE 80 diff --git a/cicd/jenkins-pipelines/build.groovy b/cicd/jenkins-pipelines/build.groovy index bae4c8a46..8302a8116 100644 --- a/cicd/jenkins-pipelines/build.groovy +++ b/cicd/jenkins-pipelines/build.groovy @@ -6,8 +6,9 @@ pipeline { environment { DOCKERHUB_CREDENTIALS = credentials('nalexx6_docker_pass') DOCKERHUB_USERNAME = "nalexx6" - NEXUS_URL = 'localhost:8081' + NEXUS_SNAPHOT_URL = 'http://localhost:8081/repository/maven-snapshots' def ARTIFACT_VERSION = sh(script: "mvn help:evaluate -Dexpression=project.version -q -DforceStdout", returnStdout: true).trim() + ARTIFACT_PATH = "target" } stages { @@ -25,14 +26,14 @@ pipeline { stage('Upload to Nexus') { steps { sh """ - mvn deploy:deploy-file -DgroupId=org -DartifactId=petclinic -Dversion=${ARTIFACT_VERSION} -Dpackaging=jar -Dfile=./target/spring-petclinic-${ARTIFACT_VERSION}.jar -DrepositoryId=maven-snapshots -Durl=http://${NEXUS_URL}/repository/maven-snapshots/ --settings settings.xml + mvn deploy:deploy-file -DgroupId=org -DartifactId=petclinic -Dversion=${ARTIFACT_VERSION} -Dpackaging=jar -Dfile=./target/petclinic-${ARTIFACT_VERSION}.jar -DrepositoryId=maven-snapshots -Durl=${NEXUS_SNAPHOT_URL} --settings settings.xml """ } } stage('Build Docker Image') { steps { script { - sh "DOCKER_BUILDKIT=0 docker build --build-arg ARTIFACT_VERSION=${ARTIFACT_VERSION} -t petclinic:${ARTIFACT_VERSION} ." + sh "DOCKER_BUILDKIT=0 docker build --build-arg ARTIFACT_VERSION=${ARTIFACT_VERSION} ARTIFACT_PATH=${ARTIFACT_PATH} -t petclinic:${ARTIFACT_VERSION} ." sh "docker tag petclinic:${ARTIFACT_VERSION} ${DOCKERHUB_USERNAME}/petclinic:${ARTIFACT_VERSION}" sh "docker login -u ${DOCKERHUB_USERNAME} -p ${DOCKERHUB_CREDENTIALS}" sh "docker push ${DOCKERHUB_USERNAME}/petclinic:${ARTIFACT_VERSION}" diff --git a/pom.xml b/pom.xml index dc6b8e722..d74f51850 100644 --- a/pom.xml +++ b/pom.xml @@ -10,8 +10,8 @@ org.springframework.samples - spring-petclinic - 3.4.0-SNAPSHOT + petclinic + 3.4.1 petclinic @@ -23,7 +23,7 @@ UTF-8 - 2024-11-28T14:37:52Z + 2025-01-13T22:19:14Z 1.0.1