mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-19 22:35:50 +00:00
Dockerfile, build fixed, artifact name changed
This commit is contained in:
parent
de98afcd93
commit
6daac88b74
3 changed files with 10 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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}"
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -10,8 +10,8 @@
|
|||
</parent>
|
||||
|
||||
<groupId>org.springframework.samples</groupId>
|
||||
<artifactId>spring-petclinic</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<artifactId>petclinic</artifactId>
|
||||
<version>3.4.1</version>
|
||||
|
||||
<name>petclinic</name>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
|||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<!-- Important for reproducible builds. Update using e.g. ./mvnw versions:set
|
||||
-DnewVersion=... -->
|
||||
<project.build.outputTimestamp>2024-11-28T14:37:52Z</project.build.outputTimestamp>
|
||||
<project.build.outputTimestamp>2025-01-13T22:19:14Z</project.build.outputTimestamp>
|
||||
|
||||
<!-- Web dependencies -->
|
||||
<webjars-locator.version>1.0.1</webjars-locator.version>
|
||||
|
|
Loading…
Reference in a new issue