From 7d7c396013ac6c405f26a945a99e9e833999b94a Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 14:34:43 -0400 Subject: [PATCH 01/27] Latest Dockerfile. --- Dockerfile | 2 +- docker-compose_spring-petclinic.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2dbfce412..1fc670953 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ COPY src ./src RUN ./mvnw clean package -DskipTests # Copy the JAR file to the app directory -COPY target/*.jar app.jar +COPY /app/target/spring-petclinic-3.3.0-SNAPSHOT.jar app.jar # Run the jar file CMD ["java", "-jar", "app.jar"] diff --git a/docker-compose_spring-petclinic.yml b/docker-compose_spring-petclinic.yml index 4187c4fe8..81bd88661 100644 --- a/docker-compose_spring-petclinic.yml +++ b/docker-compose_spring-petclinic.yml @@ -52,6 +52,7 @@ services: - jenkins_data:/var/jenkins_home - ./jenkins.yaml:/var/jenkins_home/casc_configs/jenkins.yaml - /var/run/docker.sock:/var/run/docker.sock + - ./target:/var/jenkins_home/target networks: - custom-network From 56c0156585e345ded4924629ea2858cf3401f949 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 14:39:25 -0400 Subject: [PATCH 02/27] Lastest commit --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 59ead86e9..87ed660b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -target/* bin/* build/* .gradle/* @@ -9,7 +8,6 @@ build/* .attach_pid* .idea *.iml -/target .sts4-cache/ .vscode _site/ From 3d02e1b15c791d1783baa2e5262d92b16c6d8101 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 15:09:25 -0400 Subject: [PATCH 03/27] 1 --- .gitignore | 3 ++- Dockerfile | 2 +- Jenkinsfile | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 87ed660b9..32295ffc8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +target/* bin/* build/* .gradle/* @@ -8,11 +9,11 @@ build/* .attach_pid* .idea *.iml +/target .sts4-cache/ .vscode _site/ *.css !petclinic.css - zap-report/* .DS_Store diff --git a/Dockerfile b/Dockerfile index 1fc670953..2dbfce412 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ COPY src ./src RUN ./mvnw clean package -DskipTests # Copy the JAR file to the app directory -COPY /app/target/spring-petclinic-3.3.0-SNAPSHOT.jar app.jar +COPY target/*.jar app.jar # Run the jar file CMD ["java", "-jar", "app.jar"] diff --git a/Jenkinsfile b/Jenkinsfile index 8ac23c6f0..31609f16c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,6 +25,7 @@ pipeline { echo "Docker Image built: ${dockerImage.id}" // Store the Docker image ID in the environment if needed across stages env.DOCKER_IMAGE_ID = dockerImage.id + sh 'ls -la target/' } } } From 53ef24191b0f9ca01ca386a942c5895f01326e35 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 15:14:06 -0400 Subject: [PATCH 04/27] latest --- Dockerfile | 14 ++------------ Jenkinsfile | 4 +++- docker-compose_spring-petclinic.yml | 1 - 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2dbfce412..012bb41ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,10 @@ # Use an official OpenJDK runtime as a parent image -FROM openjdk +FROM openjdk:11 # Set the working directory inside the container WORKDIR /app -# Copy the Maven wrapper and the pom.xml file -COPY .mvn/ .mvn -COPY mvnw pom.xml ./ - -# Copy the project source code -COPY src ./src - -# Package the application -RUN ./mvnw clean package -DskipTests - -# Copy the JAR file to the app directory +# Copy the built JAR file from the build context COPY target/*.jar app.jar # Run the jar file diff --git a/Jenkinsfile b/Jenkinsfile index 31609f16c..5142de2f8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,15 +21,17 @@ pipeline { steps { script { echo "Building Docker Image..." + // Ensure Maven build is executed + sh './mvnw clean package -DskipTests' def dockerImage = docker.build("spring-petclinic") echo "Docker Image built: ${dockerImage.id}" // Store the Docker image ID in the environment if needed across stages env.DOCKER_IMAGE_ID = dockerImage.id - sh 'ls -la target/' } } } + } post { diff --git a/docker-compose_spring-petclinic.yml b/docker-compose_spring-petclinic.yml index 81bd88661..4187c4fe8 100644 --- a/docker-compose_spring-petclinic.yml +++ b/docker-compose_spring-petclinic.yml @@ -52,7 +52,6 @@ services: - jenkins_data:/var/jenkins_home - ./jenkins.yaml:/var/jenkins_home/casc_configs/jenkins.yaml - /var/run/docker.sock:/var/run/docker.sock - - ./target:/var/jenkins_home/target networks: - custom-network From d0bfd8b78eb59d10bddc30f89dcbef288f5fcfbe Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 15:21:40 -0400 Subject: [PATCH 05/27] latest --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5142de2f8..ff8a76707 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,10 +37,10 @@ pipeline { post { always { script { - // Use the saved Docker image ID from the environment if needed if (env.DOCKER_IMAGE_ID) { echo "Stopping and removing Docker Image with ID: ${env.DOCKER_IMAGE_ID}" - docker.rmi(env.DOCKER_IMAGE_ID) + // Using shell command to remove Docker image + sh "docker rmi ${env.DOCKER_IMAGE_ID}" } } } From c556ebc30878cfc130fcea4688bc38034e9225ed Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 15:33:16 -0400 Subject: [PATCH 06/27] latest --- Dockerfile | 29 +++++++++++++++++++---------- Jenkinsfile | 7 +++---- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 012bb41ca..91b031ec3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,23 @@ -# Use an official OpenJDK runtime as a parent image -FROM openjdk:11 - -# Set the working directory inside the container +# First stage: Build the application using Maven +FROM maven:3.8.1-openjdk-17 AS build WORKDIR /app -# Copy the built JAR file from the build context -COPY target/*.jar app.jar +# Copy the Maven wrapper and the pom.xml file +COPY .mvn/ .mvn +COPY mvnw pom.xml ./ + +# Copy the project source code +COPY src ./src + +# Package the application +RUN ./mvnw package + +# Second stage: Use an official OpenJDK runtime as a parent image +FROM openjdk +WORKDIR /app + +# Copy the JAR file from the build stage +COPY --from=build /app/target/*.jar app.jar # Run the jar file -CMD ["java", "-jar", "app.jar"] - -# Expose the port the app runs on -EXPOSE 8080 +CMD ["java", "-jar", "app"] \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index ff8a76707..bd0ff8d89 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,8 +21,6 @@ pipeline { steps { script { echo "Building Docker Image..." - // Ensure Maven build is executed - sh './mvnw clean package -DskipTests' def dockerImage = docker.build("spring-petclinic") echo "Docker Image built: ${dockerImage.id}" // Store the Docker image ID in the environment if needed across stages @@ -31,16 +29,17 @@ pipeline { } } + // Further stages would reference env.DOCKER_IMAGE_ID if needed } post { always { script { + // Use the saved Docker image ID from the environment if needed if (env.DOCKER_IMAGE_ID) { echo "Stopping and removing Docker Image with ID: ${env.DOCKER_IMAGE_ID}" - // Using shell command to remove Docker image - sh "docker rmi ${env.DOCKER_IMAGE_ID}" + docker.rmi(env.DOCKER_IMAGE_ID) } } } From 39c4687fa6a2be077165db66aac817ac7788d820 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 21:28:09 -0400 Subject: [PATCH 07/27] revert Dockerfile --- Dockerfile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 91b031ec3..2dbfce412 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ -# First stage: Build the application using Maven -FROM maven:3.8.1-openjdk-17 AS build +# Use an official OpenJDK runtime as a parent image +FROM openjdk + +# Set the working directory inside the container WORKDIR /app # Copy the Maven wrapper and the pom.xml file @@ -10,14 +12,13 @@ COPY mvnw pom.xml ./ COPY src ./src # Package the application -RUN ./mvnw package +RUN ./mvnw clean package -DskipTests -# Second stage: Use an official OpenJDK runtime as a parent image -FROM openjdk -WORKDIR /app - -# Copy the JAR file from the build stage -COPY --from=build /app/target/*.jar app.jar +# Copy the JAR file to the app directory +COPY target/*.jar app.jar # Run the jar file -CMD ["java", "-jar", "app"] \ No newline at end of file +CMD ["java", "-jar", "app.jar"] + +# Expose the port the app runs on +EXPOSE 8080 From c95b67697b1d251961f0d0f9dc26dd3f2b4c2aab Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 21:32:52 -0400 Subject: [PATCH 08/27] Latest update --- .gitignore | 2 -- Dockerfile | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 32295ffc8..a68b56532 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -target/* bin/* build/* .gradle/* @@ -9,7 +8,6 @@ build/* .attach_pid* .idea *.iml -/target .sts4-cache/ .vscode _site/ diff --git a/Dockerfile b/Dockerfile index 2dbfce412..6a6ac343a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ COPY mvnw pom.xml ./ COPY src ./src # Package the application -RUN ./mvnw clean package -DskipTests +RUN ./mvnw clean package -Dmaven.test.skip=true # Copy the JAR file to the app directory COPY target/*.jar app.jar From 8dc7f3005d7a331f9e3f7b807284c2ecbf7dc1d6 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 21:38:27 -0400 Subject: [PATCH 09/27] latest Dockerfile --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6a6ac343a..f6fb1b08b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,9 +13,10 @@ COPY src ./src # Package the application RUN ./mvnw clean package -Dmaven.test.skip=true +RUN ls -alh /app/target/ # This will list the contents of the target directory # Copy the JAR file to the app directory -COPY target/*.jar app.jar +COPY target/spring-petclinic-3.3.0-SNAPSHOT.jar app.jar # Run the jar file CMD ["java", "-jar", "app.jar"] From b2dc648b14dd89ef77bbcb1ef37c821556e98a63 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 21:40:15 -0400 Subject: [PATCH 10/27] latest Dockerfile --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f6fb1b08b..4da6d371d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,9 +13,12 @@ COPY src ./src # Package the application RUN ./mvnw clean package -Dmaven.test.skip=true -RUN ls -alh /app/target/ # This will list the contents of the target directory + +WORKDIR /app +RUN ls -alh /app/target/ # Copy the JAR file to the app directory +WORKDIR /app COPY target/spring-petclinic-3.3.0-SNAPSHOT.jar app.jar # Run the jar file From a5c9b26d61e690de07ad539164283afce0a11331 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 21:42:23 -0400 Subject: [PATCH 11/27] latest Dockerfile --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4da6d371d..2715b2a0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +ARG CACHEBUST=1 # Use an official OpenJDK runtime as a parent image FROM openjdk @@ -14,11 +15,10 @@ COPY src ./src # Package the application RUN ./mvnw clean package -Dmaven.test.skip=true -WORKDIR /app +# Verify the build output RUN ls -alh /app/target/ # Copy the JAR file to the app directory -WORKDIR /app COPY target/spring-petclinic-3.3.0-SNAPSHOT.jar app.jar # Run the jar file From e03f4fa444c43912fc1b5baafede0bc69f153982 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 21:46:14 -0400 Subject: [PATCH 12/27] latest Dockerfile --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2715b2a0e..9363e22c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,3 @@ -ARG CACHEBUST=1 # Use an official OpenJDK runtime as a parent image FROM openjdk From 1d4108b7f52dd9fe1412c3997a55497f9eed33cd Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 21:47:30 -0400 Subject: [PATCH 13/27] latest Dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 9363e22c6..2715b2a0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +ARG CACHEBUST=1 # Use an official OpenJDK runtime as a parent image FROM openjdk From e790e245853d216fd8d67a9adde9b6404954d0c1 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 21:52:39 -0400 Subject: [PATCH 14/27] latest Dockerfile --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2715b2a0e..b665dc3df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,3 @@ -ARG CACHEBUST=1 # Use an official OpenJDK runtime as a parent image FROM openjdk @@ -19,7 +18,7 @@ RUN ./mvnw clean package -Dmaven.test.skip=true RUN ls -alh /app/target/ # Copy the JAR file to the app directory -COPY target/spring-petclinic-3.3.0-SNAPSHOT.jar app.jar +COPY /app/target/spring-petclinic-3.3.0-SNAPSHOT.jar app.jar # Run the jar file CMD ["java", "-jar", "app.jar"] From a60b181eb993b1b7ba42bd4e9393043bc4aae70e Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 21:53:18 -0400 Subject: [PATCH 15/27] latest Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b665dc3df..71ebac026 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN ./mvnw clean package -Dmaven.test.skip=true RUN ls -alh /app/target/ # Copy the JAR file to the app directory -COPY /app/target/spring-petclinic-3.3.0-SNAPSHOT.jar app.jar +COPY /app/target/spring-petclinic-3.3.0-SNAPSHOT.jar.original app.jar # Run the jar file CMD ["java", "-jar", "app.jar"] From 19dbd094ecad0b33b748fdbc2a27bba192df81e6 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 21:57:08 -0400 Subject: [PATCH 16/27] test --- Dockerfile | 5 +---- Jenkinsfile | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 71ebac026..6a6ac343a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,11 +14,8 @@ COPY src ./src # Package the application RUN ./mvnw clean package -Dmaven.test.skip=true -# Verify the build output -RUN ls -alh /app/target/ - # Copy the JAR file to the app directory -COPY /app/target/spring-petclinic-3.3.0-SNAPSHOT.jar.original app.jar +COPY target/*.jar app.jar # Run the jar file CMD ["java", "-jar", "app.jar"] diff --git a/Jenkinsfile b/Jenkinsfile index bd0ff8d89..5198b7d29 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,7 @@ pipeline { steps { script { echo "Building Docker Image..." - def dockerImage = docker.build("spring-petclinic") + def dockerImage = docker.build("spring-petclinic", "--no-cache .") echo "Docker Image built: ${dockerImage.id}" // Store the Docker image ID in the environment if needed across stages env.DOCKER_IMAGE_ID = dockerImage.id From 67c8dc137a6ce989ba2a661db61c7bad7335bfe8 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 22:15:16 -0400 Subject: [PATCH 17/27] latest --- jenkins.yaml | 203 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 164 insertions(+), 39 deletions(-) diff --git a/jenkins.yaml b/jenkins.yaml index 80453548e..e92796c73 100644 --- a/jenkins.yaml +++ b/jenkins.yaml @@ -1,47 +1,172 @@ +credentials: + system: + domainCredentials: + - credentials: + - string: + description: "github" + id: "3afa055d-73a9-4aff-aa10-9d385042650c" + scope: GLOBAL + secret: "{AQAAABAAAAAw/i6NBKJoBVdluXYKvFf1I+3/6aJWsbknhkIW7h0ipryqjIzcofzR7k33bNlQqZKUP1gSMzy7EavUnHEt7dunnQ==}" + - string: + id: "58b57ccb-9fc0-4180-9e6c-91b9df3a6440" + scope: GLOBAL + secret: "{AQAAABAAAAAwzL567eZhfHhwsevOonI290HxU4cFwbVCxg7dwlxIglQAiAenE40WxSmN0JnlO4mZoxNk6LWV02LsmfO9ozcsNQ==}" jenkins: - systemMessage: "Jenkins configured automatically by Jenkins Configuration as Code plugin\n\n" - securityRealm: - local: - allowsSignup: false - users: - - id: "admin" - password: "${JENKINS_ADMIN_PASSWORD:-admin}" + agentProtocols: + - "JNLP4-connect" + - "Ping" authorizationStrategy: loggedInUsersCanDoAnything: allowAnonymousRead: false + crumbIssuer: + standard: + excludeClientIPFromCrumb: false + disableRememberMe: false + disabledAdministrativeMonitors: + - "jenkins.diagnostics.ControllerExecutorsNoAgents" + - "hudson.util.DoubleLaunchChecker" + labelAtoms: + - name: "built-in" + markupFormatter: "plainText" + mode: NORMAL + myViewsTabBar: "standard" + nodeMonitors: + - "architecture" + - "clock" + - diskSpace: + freeSpaceThreshold: "1GiB" + freeSpaceWarningThreshold: "2GiB" + - "swapSpace" + - tmpSpace: + freeSpaceThreshold: "1GiB" + freeSpaceWarningThreshold: "2GiB" + - "responseTime" + numExecutors: 2 + primaryView: + all: + name: "all" + projectNamingStrategy: "standard" + quietPeriod: 5 + remotingSecurity: + enabled: true + scmCheckoutRetryCount: 0 + securityRealm: + local: + allowsSignup: false + enableCaptcha: false + users: + - id: "admin" + name: "admin" + properties: + - "apiToken" + - "consoleUrlProvider" + - mailer: + emailAddress: "lihanzhan@gmail.com" + - "favorite" + - preferredProvider: + providerId: "default" + - "experimentalFlags" + slaveAgentPort: 50000 + systemMessage: |+ + Jenkins configured automatically by Jenkins Configuration as Code plugin + updateCenter: + sites: + - id: "default" + url: "https://updates.jenkins.io/update-center.json" + views: + - all: + name: "all" + viewsTabBar: "standard" +globalCredentialsConfiguration: + configuration: + providerFilter: "none" + typeFilter: "none" +appearance: + prism: + theme: PRISM +security: + apiToken: + creationOfLegacyTokenEnabled: false + tokenGenerationOnCreationEnabled: false + usageStatisticsEnabled: true + gitHooks: + allowedOnAgents: true + allowedOnController: true + gitHostKeyVerificationConfiguration: + sshHostKeyVerificationStrategy: "knownHostsFileVerificationStrategy" + sSHD: + port: -1 + scriptApproval: + approvedSignatures: + - "method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object" unclassified: + bitbucketEndpointConfiguration: + endpoints: + - bitbucketCloudEndpoint: + enableCache: false + manageHooks: false + repositoriesCacheDuration: 0 + teamCacheDuration: 0 + buildDiscarders: + configuredBuildDiscarders: + - "jobBuildDiscarder" + fingerprints: + fingerprintCleanupDisabled: false + storage: "file" + gitHubConfiguration: + apiRateLimitChecker: NoThrottle + gitHubPluginConfig: + hookSecretConfigs: + - credentialsId: "3afa055d-73a9-4aff-aa10-9d385042650c" + hookUrl: "http://localhost:8080/github-webhook/" + githubPullRequests: + actualiseOnFactory: false + junitTestResultStorage: + storage: "file" location: + adminAddress: "address not configured yet " url: "http://localhost:8080/" -# prometheus: -# defaultQuantiles: -# - name: "0.5" -# value: 0.5 -# - name: "0.9" -# value: 0.9 -# - name: "0.99" -# value: 0.99 -# defaultBuckets: -# - name: "0.1" -# value: 0.1 -# - name: "0.2" -# value: 0.2 -# - name: "0.5" -# value: 0.5 -# - name: "1.0" -# value: 1.0 -# - name: "2.5" -# value: 2.5 -# - name: "5.0" -# value: 5.0 -# - name: "10.0" -# value: 10.0 -# -#tools: -# installations: -# - name: "JDK11" -# jdkInstaller: -# id: "jdk-11.0.2+9" -# - name: "Maven3" -# mavenInstaller: -# id: "maven-3.6.3" + mailer: + charset: "UTF-8" + useSsl: false + useTls: false + mavenModuleSet: + localRepository: "default" + pollSCM: + pollingThreadCount: 10 + prometheusConfiguration: + appendParamLabel: false + appendStatusLabel: false + collectCodeCoverage: false + collectDiskUsage: true + collectNodeStatus: true + collectingMetricsPeriodInSeconds: 120 + countAbortedBuilds: true + countFailedBuilds: true + countNotBuiltBuilds: true + countSuccessfulBuilds: true + countUnstableBuilds: true + defaultNamespace: "default" + fetchTestResults: true + jobAttributeName: "jenkins_job" + path: "prometheus" + perBuildMetrics: false + processingDisabledBuilds: false + useAuthenticatedEndpoint: false + scmGit: + addGitTagAction: false + allowSecondFetch: false + createAccountBasedOnEmail: false + disableGitToolChooser: false + hideCredentials: false + showEntireCommitSummaryInChanges: false + useExistingAccountWithSameEmail: false +tool: + git: + installations: + - home: "git" + name: "Default" + mavenGlobalConfig: + globalSettingsProvider: "standard" + settingsProvider: "standard" From 2e318f295e729b0348b4f370fc64c2dcbffc93a6 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 22:43:31 -0400 Subject: [PATCH 18/27] Test --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6a6ac343a..2dbfce412 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ COPY mvnw pom.xml ./ COPY src ./src # Package the application -RUN ./mvnw clean package -Dmaven.test.skip=true +RUN ./mvnw clean package -DskipTests # Copy the JAR file to the app directory COPY target/*.jar app.jar From 6719cc74d27df6668174d62d587de693bc819e34 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sat, 27 Jul 2024 23:19:30 -0400 Subject: [PATCH 19/27] test --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2dbfce412..2a1eed127 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,10 +12,12 @@ COPY mvnw pom.xml ./ COPY src ./src # Package the application -RUN ./mvnw clean package -DskipTests +RUN ./mvnw clean package -Dmaven.test.skip=true +RUN ls -alh /app/target/ # Copy the JAR file to the app directory -COPY target/*.jar app.jar +WORKDIR /app +COPY /var/jenkins_home/workspace/ing-petclinic_use_docker_compose/target/spring-petclinic-3.3.0-SNAPSHOT.jar /app/app.jar # Run the jar file CMD ["java", "-jar", "app.jar"] From 95786ffbfd1c1190bf146d8e924b3628d0a982dd Mon Sep 17 00:00:00 2001 From: Lihan Date: Sun, 28 Jul 2024 00:48:05 -0400 Subject: [PATCH 20/27] test --- Dockerfile | 8 +++++--- Jenkinsfile | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2a1eed127..213f27453 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,13 +11,15 @@ COPY mvnw pom.xml ./ # Copy the project source code COPY src ./src +# Introduce an ARG to act as a cache breaker +ARG CACHEBUSTER=unknown + # Package the application RUN ./mvnw clean package -Dmaven.test.skip=true RUN ls -alh /app/target/ -# Copy the JAR file to the app directory -WORKDIR /app -COPY /var/jenkins_home/workspace/ing-petclinic_use_docker_compose/target/spring-petclinic-3.3.0-SNAPSHOT.jar /app/app.jar +# Move the JAR file to the app directory (update this if necessary based on actual JAR names) +COPY target/*.jar /app/app.jar # Run the jar file CMD ["java", "-jar", "app.jar"] diff --git a/Jenkinsfile b/Jenkinsfile index 5198b7d29..fb309ad73 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,8 @@ pipeline { steps { script { echo "Building Docker Image..." - def dockerImage = docker.build("spring-petclinic", "--no-cache .") + // Add a cache buster to force no-cache on certain steps + def dockerImage = docker.build("spring-petclinic", "--build-arg CACHEBUSTER=$(date +%s) --no-cache .") echo "Docker Image built: ${dockerImage.id}" // Store the Docker image ID in the environment if needed across stages env.DOCKER_IMAGE_ID = dockerImage.id From b7bcdf16bd8cb73f37302b1575041e5a4259bb45 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sun, 28 Jul 2024 00:49:35 -0400 Subject: [PATCH 21/27] w/e --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fb309ad73..abf3d3ef3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,8 +21,8 @@ pipeline { steps { script { echo "Building Docker Image..." - // Add a cache buster to force no-cache on certain steps - def dockerImage = docker.build("spring-petclinic", "--build-arg CACHEBUSTER=$(date +%s) --no-cache .") + // Correctly escape dollar signs in Groovy string + def dockerImage = docker.build("spring-petclinic", "--build-arg CACHEBUSTER=\\$(date +%s) --no-cache .") echo "Docker Image built: ${dockerImage.id}" // Store the Docker image ID in the environment if needed across stages env.DOCKER_IMAGE_ID = dockerImage.id From 57045506f4e5da8daa5b55ab26a1e749b0c66b63 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sun, 28 Jul 2024 00:53:46 -0400 Subject: [PATCH 22/27] w/e --- Jenkinsfile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index abf3d3ef3..9501332f3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,12 +17,21 @@ pipeline { } } + stage('Prepare Environment') { + steps { + script { + sh "pwd" // Prints the current working directory + sh "ls -alh" // Lists all files in the current directory + } + } + } + stage('Build Docker Image') { steps { script { echo "Building Docker Image..." // Correctly escape dollar signs in Groovy string - def dockerImage = docker.build("spring-petclinic", "--build-arg CACHEBUSTER=\\$(date +%s) --no-cache .") + def dockerImage = docker.build("spring-petclinic", "--no-cache --build-arg FORCE_REBUILD=$(date +%s) .") echo "Docker Image built: ${dockerImage.id}" // Store the Docker image ID in the environment if needed across stages env.DOCKER_IMAGE_ID = dockerImage.id From d2b23badf3c9a0fa336d6a655790d71e325ac8ea Mon Sep 17 00:00:00 2001 From: Lihan Date: Sun, 28 Jul 2024 00:55:11 -0400 Subject: [PATCH 23/27] w/e --- Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 213f27453..ae99560fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,12 +11,11 @@ COPY mvnw pom.xml ./ # Copy the project source code COPY src ./src -# Introduce an ARG to act as a cache breaker -ARG CACHEBUSTER=unknown +# Use an argument to force a rebuild +ARG FORCE_REBUILD=unknown # Package the application -RUN ./mvnw clean package -Dmaven.test.skip=true -RUN ls -alh /app/target/ +RUN ./mvnw clean package -Dmaven.test.skip=true && ls -alh /app/target/ # Move the JAR file to the app directory (update this if necessary based on actual JAR names) COPY target/*.jar /app/app.jar From d6a0b57127db323f65dfb3f142461756bfbd9a51 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sun, 28 Jul 2024 01:05:45 -0400 Subject: [PATCH 24/27] ahhhh --- Dockerfile | 19 +++---------------- Jenkinsfile | 10 ++++------ 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index ae99560fd..ce19ac4ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,11 @@ # Use an official OpenJDK runtime as a parent image -FROM openjdk +FROM openjdk:11-jdk-slim # Set the working directory inside the container WORKDIR /app -# Copy the Maven wrapper and the pom.xml file -COPY .mvn/ .mvn -COPY mvnw pom.xml ./ - -# Copy the project source code -COPY src ./src - -# Use an argument to force a rebuild -ARG FORCE_REBUILD=unknown - -# Package the application -RUN ./mvnw clean package -Dmaven.test.skip=true && ls -alh /app/target/ - -# Move the JAR file to the app directory (update this if necessary based on actual JAR names) -COPY target/*.jar /app/app.jar +# Copy the JAR file to the app directory (adjust this path according to your actual JAR file name in the target directory) +COPY target/*.jar app.jar # Run the jar file CMD ["java", "-jar", "app.jar"] diff --git a/Jenkinsfile b/Jenkinsfile index 9501332f3..dfd48c586 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,11 +17,11 @@ pipeline { } } - stage('Prepare Environment') { + stage('Build JAR') { steps { script { - sh "pwd" // Prints the current working directory - sh "ls -alh" // Lists all files in the current directory + echo "Building JAR..." + sh './mvnw clean package -Dmaven.test.skip=true' } } } @@ -30,8 +30,7 @@ pipeline { steps { script { echo "Building Docker Image..." - // Correctly escape dollar signs in Groovy string - def dockerImage = docker.build("spring-petclinic", "--no-cache --build-arg FORCE_REBUILD=$(date +%s) .") + def dockerImage = docker.build("spring-petclinic", "--no-cache .") echo "Docker Image built: ${dockerImage.id}" // Store the Docker image ID in the environment if needed across stages env.DOCKER_IMAGE_ID = dockerImage.id @@ -40,7 +39,6 @@ pipeline { } // Further stages would reference env.DOCKER_IMAGE_ID if needed - } post { From a2be3cc8c44cc625e28aad7babb7e1923dae3d3d Mon Sep 17 00:00:00 2001 From: Lihan Date: Sun, 28 Jul 2024 01:09:29 -0400 Subject: [PATCH 25/27] ahwjiasjdojiqowe --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index dfd48c586..a937144b0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -47,7 +47,8 @@ pipeline { // Use the saved Docker image ID from the environment if needed if (env.DOCKER_IMAGE_ID) { echo "Stopping and removing Docker Image with ID: ${env.DOCKER_IMAGE_ID}" - docker.rmi(env.DOCKER_IMAGE_ID) + def dockerImage = docker.image(env.DOCKER_IMAGE_ID) + dockerImage.remove() } } } From 65dc656eb77feec29667b16296ea48d2a1be8a06 Mon Sep 17 00:00:00 2001 From: Lihan Date: Sun, 28 Jul 2024 01:12:37 -0400 Subject: [PATCH 26/27] asjdioqwjoezxc --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a937144b0..2810eab96 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -47,8 +47,7 @@ pipeline { // Use the saved Docker image ID from the environment if needed if (env.DOCKER_IMAGE_ID) { echo "Stopping and removing Docker Image with ID: ${env.DOCKER_IMAGE_ID}" - def dockerImage = docker.image(env.DOCKER_IMAGE_ID) - dockerImage.remove() + docker.image(env.DOCKER_IMAGE_ID).remove() } } } From 3e3d92ae5d9a5dc73214a6c7d10781938709d3ba Mon Sep 17 00:00:00 2001 From: Lihan Date: Sun, 28 Jul 2024 01:36:42 -0400 Subject: [PATCH 27/27] saduijqwo --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2810eab96..a0428726d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -47,7 +47,7 @@ pipeline { // Use the saved Docker image ID from the environment if needed if (env.DOCKER_IMAGE_ID) { echo "Stopping and removing Docker Image with ID: ${env.DOCKER_IMAGE_ID}" - docker.image(env.DOCKER_IMAGE_ID).remove() + sh "docker rmi -f ${env.DOCKER_IMAGE_ID}" } } }