From d01f220d2710806dd95872204a7fb15d98d060fb Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 14:38:54 -0600 Subject: [PATCH 01/18] add version --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8d12374..60aefc9 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ tmp .factorypath src/resources/fault libs +*version.json # Node node_modules -- GitLab From 9fa35008e771a7a452f2843259d77bd8576d3671 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 14:39:03 -0600 Subject: [PATCH 02/18] import app version --- build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle b/build.gradle index 2fe8d69..6b485bc 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ plugins { id "com.github.johnrengelman.shadow" version "${shadowVersion}" id "com.github.node-gradle.node" version "${nodePluginVersion}" id "com.github.spotbugs" version "${spotbugsVersion}" + id "com.palantir.git-version" version "${gitVersionVersion}" id "com.star-zero.gradle.githook" version "${githooksVersion}" id "eclipse-wtp" id "io.micronaut.application" version "${micronautPluginVersion}" @@ -21,6 +22,7 @@ java { withSourcesJar() } +apply from: "${projectDir}/gradle/app-version.gradle" apply from: "${projectDir}/gradle/dependencies.gradle" apply from: "${projectDir}/gradle/git-hooks.gradle" apply from: "${projectDir}/gradle/node.gradle" -- GitLab From 33482373651a4730a0be3a46c9389fa091abf4e6 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 14:39:08 -0600 Subject: [PATCH 03/18] update deps --- gradle.properties | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 157f85c..8bd1b10 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,5 @@ githooksVersion = 1.2.0 +gitVersionVersion = 0.15.0 jacksonVersion = 2.9.0 junitVersion = 5.8.2 logbackVersion = 1.2.3 @@ -8,8 +9,8 @@ micronautPluginVersion = 3.1.1 nodePluginVersion = 3.0.1 nodeVersion = 16.3.0 nshmFaultSectionsTag = v0.1 -nshmpLibVersion = 1.0.4 -nshmpWsUtilsVersion = 0.3.5 +nshmpLibVersion = 1.0.6 +nshmpWsUtilsVersion = 0.3.7 shadowVersion = 7.1.2 spotbugsVersion = 4.7.0 spotlessVersion = 6.0.4 -- GitLab From bcd6ac6fcb055a94a0eccc3f495e07b57f831816 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 14:39:15 -0600 Subject: [PATCH 04/18] create version file --- gradle/app-version.gradle | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 gradle/app-version.gradle diff --git a/gradle/app-version.gradle b/gradle/app-version.gradle new file mode 100644 index 0000000..026c82f --- /dev/null +++ b/gradle/app-version.gradle @@ -0,0 +1,23 @@ +apply plugin: "com.palantir.git-version" + +tasks.withType(JavaCompile) { + doFirst { + def versionFile = new File("${projectDir}/src/main/resources/version/nshmp-ws-version.json") + new File(versionFile.getParent()).mkdirs() + def details = versionDetails() + def ciProjectUrl = System.getenv("CI_PROJECT_URL") + def versionInfo = [ + branchName: details.branchName, + commitDistance: details.commitDistance, + gitHash: details.gitHash, + gitHashFull: details.gitHashFull, + isCleanTag: details.isCleanTag, + lastTag: details.lastTag, + projectName: project.name, + url: ciProjectUrl ? ciProjectUrl : 'git config --get remote.origin.url'.execute().text.replace('\n', ''), + version: details.version, + ] + def json = groovy.json.JsonOutput.toJson(versionInfo) + versionFile.write(groovy.json.JsonOutput.prettyPrint(json)) + } +} -- GitLab From ee823a1bffe6bb195ce516bac4c5aec34ae2f905 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 14:39:29 -0600 Subject: [PATCH 05/18] read version files --- .../usgs/earthquake/nshmp/www/WsVersion.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/gov/usgs/earthquake/nshmp/www/WsVersion.java diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/WsVersion.java b/src/main/java/gov/usgs/earthquake/nshmp/www/WsVersion.java new file mode 100644 index 0000000..e5b7af1 --- /dev/null +++ b/src/main/java/gov/usgs/earthquake/nshmp/www/WsVersion.java @@ -0,0 +1,23 @@ +package gov.usgs.earthquake.nshmp.www; + +import com.google.common.io.Resources; + +import gov.usgs.earthquake.nshmp.internal.AppVersion; +import gov.usgs.earthquake.nshmp.internal.LibVersion; + +public class WsVersion implements AppVersion { + + public static VersionInfo[] appVersions() { + VersionInfo[] versions = { + new WsVersion().getVersionInfo(), + new LibVersion().getVersionInfo(), + new WsUtilsVersion().getVersionInfo(), + }; + return versions; + } + + public VersionInfo getVersionInfo() { + var resource = Resources.getResource("version/nshmp-ws-version.json"); + return AppVersion.versionInfo(resource); + } +} -- GitLab From 197bc7a9b7e098319f51b2e12371481187dd981b Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 14:39:37 -0600 Subject: [PATCH 06/18] add metadata --- src/main/java/gov/usgs/earthquake/nshmp/www/Utils.java | 1 + .../java/gov/usgs/earthquake/nshmp/www/gmm/GmmService.java | 5 +++++ .../java/gov/usgs/earthquake/nshmp/www/gmm/ServiceUtil.java | 3 +++ .../earthquake/nshmp/www/services/FaultSectionsService.java | 6 ++++++ .../gov/usgs/earthquake/nshmp/www/services/GpsService.java | 4 ++++ .../gov/usgs/earthquake/nshmp/www/services/GulfService.java | 4 ++++ 6 files changed, 23 insertions(+) diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/Utils.java b/src/main/java/gov/usgs/earthquake/nshmp/www/Utils.java index 78fb378..9b39df8 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/www/Utils.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/www/Utils.java @@ -70,6 +70,7 @@ public class Utils { var svcResponse = ResponseBody.error() .name(name) .url(url) + .metadata(new ResponseMetadata(WsVersion.appVersions())) .request(msg) .response(url) .build(); diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/gmm/GmmService.java b/src/main/java/gov/usgs/earthquake/nshmp/www/gmm/GmmService.java index 8bff81f..f9c9790 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/www/gmm/GmmService.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/www/gmm/GmmService.java @@ -17,6 +17,8 @@ import gov.usgs.earthquake.nshmp.gmm.Gmm; import gov.usgs.earthquake.nshmp.gmm.GmmInput; import gov.usgs.earthquake.nshmp.gmm.Imt; import gov.usgs.earthquake.nshmp.www.ResponseBody; +import gov.usgs.earthquake.nshmp.www.ResponseMetadata; +import gov.usgs.earthquake.nshmp.www.WsVersion; import gov.usgs.earthquake.nshmp.www.gmm.GmmCalc.GmmData; import gov.usgs.earthquake.nshmp.www.gmm.XyDataGroup.EpiSeries; @@ -119,6 +121,7 @@ class GmmService { var body = ResponseBody.success() .name(request.serviceId.name) .url(request.http.getUri().getPath()) + .metadata(new ResponseMetadata(WsVersion.appVersions())) .request(request) .response(response) .build(); @@ -143,6 +146,7 @@ class GmmService { var body = ResponseBody.success() .name(request.serviceId.name) .url(request.http.getUri().getPath()) + .metadata(new ResponseMetadata(WsVersion.appVersions())) .request(request) .response(response) .build(); @@ -199,6 +203,7 @@ class GmmService { var body = ResponseBody.success() .name(request.serviceId.name) .url(request.http.getUri().getPath()) + .metadata(new ResponseMetadata(WsVersion.appVersions())) .request(request) .response(response) .build(); diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/gmm/ServiceUtil.java b/src/main/java/gov/usgs/earthquake/nshmp/www/gmm/ServiceUtil.java index f817cc4..438f574 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/www/gmm/ServiceUtil.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/www/gmm/ServiceUtil.java @@ -46,7 +46,9 @@ import gov.usgs.earthquake.nshmp.gmm.GmmInput.Constraints; import gov.usgs.earthquake.nshmp.gmm.GmmInput.Field; import gov.usgs.earthquake.nshmp.gmm.Imt; import gov.usgs.earthquake.nshmp.www.ResponseBody; +import gov.usgs.earthquake.nshmp.www.ResponseMetadata; import gov.usgs.earthquake.nshmp.www.WsUtils; +import gov.usgs.earthquake.nshmp.www.WsVersion; import gov.usgs.earthquake.nshmp.www.gmm.GmmService.Id; import gov.usgs.earthquake.nshmp.www.meta.EnumParameter; @@ -132,6 +134,7 @@ class ServiceUtil { return ResponseBody.<String, MetadataResponse> usage() .name(service.name) .url(url) + .metadata(new ResponseMetadata(WsVersion.appVersions())) .request(url) .response(new MetadataResponse(request, service)) .build(); diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/services/FaultSectionsService.java b/src/main/java/gov/usgs/earthquake/nshmp/www/services/FaultSectionsService.java index bbe91f4..2d4577d 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/www/services/FaultSectionsService.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/www/services/FaultSectionsService.java @@ -21,9 +21,11 @@ import gov.usgs.earthquake.nshmp.geo.json.GeoJson; import gov.usgs.earthquake.nshmp.internal.UsRegion; import gov.usgs.earthquake.nshmp.model.SourceFeature; import gov.usgs.earthquake.nshmp.www.ResponseBody; +import gov.usgs.earthquake.nshmp.www.ResponseMetadata; import gov.usgs.earthquake.nshmp.www.Utils; import gov.usgs.earthquake.nshmp.www.Utils.Key; import gov.usgs.earthquake.nshmp.www.WsUtils; +import gov.usgs.earthquake.nshmp.www.WsVersion; import gov.usgs.earthquake.nshmp.www.fault.FaultGroup; import gov.usgs.earthquake.nshmp.www.fault.FaultSections; import gov.usgs.earthquake.nshmp.www.fault.NshmFaultSection; @@ -146,6 +148,7 @@ public class FaultSectionsService { var response = ResponseBody.success() .name(SERVICE_NAME) .url(request.getUri().getPath()) + .metadata(new ResponseMetadata(WsVersion.appVersions())) .request(requestData) .response(builder.build().toJsonTree()) .build(); @@ -171,6 +174,7 @@ public class FaultSectionsService { var response = ResponseBody.success() .name(SERVICE_NAME) .url(request.getUri().getPath()) + .metadata(new ResponseMetadata(WsVersion.appVersions())) .request(requestData) .response(builder.build().toJsonTree()) .build(); @@ -208,6 +212,7 @@ public class FaultSectionsService { var response = ResponseBody.success() .name(SERVICE_NAME) .url(request.getUri().getPath()) + .metadata(new ResponseMetadata(WsVersion.appVersions())) .request(requestData) .response(builder.build().toJsonTree()) .build(); @@ -285,6 +290,7 @@ public class FaultSectionsService { return ResponseBody.<String, MetadataResponse> usage() .name(SERVICE_NAME) .url(url) + .metadata(new ResponseMetadata(WsVersion.appVersions())) .request(url) .response(new MetadataResponse(request)) .build(); diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/services/GpsService.java b/src/main/java/gov/usgs/earthquake/nshmp/www/services/GpsService.java index 030355d..5daff37 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/www/services/GpsService.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/www/services/GpsService.java @@ -6,8 +6,10 @@ import static gov.usgs.earthquake.nshmp.www.WsUtils.checkValue; import java.util.EnumSet; import gov.usgs.earthquake.nshmp.www.ResponseBody; +import gov.usgs.earthquake.nshmp.www.ResponseMetadata; import gov.usgs.earthquake.nshmp.www.Utils; import gov.usgs.earthquake.nshmp.www.Utils.Key; +import gov.usgs.earthquake.nshmp.www.WsVersion; import gov.usgs.earthquake.nshmp.www.gps.GpsDataSet; import gov.usgs.earthquake.nshmp.www.gps.GpsDataSets; import gov.usgs.earthquake.nshmp.www.meta.EnumParameter; @@ -72,6 +74,7 @@ public class GpsService { var response = ResponseBody.success() .name(SERVICE_NAME) .url(request.getUri().getPath()) + .metadata(new ResponseMetadata(WsVersion.appVersions())) .request(requestData) .response(values) .build(); @@ -121,6 +124,7 @@ public class GpsService { return ResponseBody.<String, MetadataResponse> usage() .name(SERVICE_NAME) .url(url) + .metadata(new ResponseMetadata(WsVersion.appVersions())) .request(url) .response(new MetadataResponse(request)) .build(); diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/services/GulfService.java b/src/main/java/gov/usgs/earthquake/nshmp/www/services/GulfService.java index e5b12ee..9bcddc7 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/www/services/GulfService.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/www/services/GulfService.java @@ -8,8 +8,10 @@ import com.google.gson.JsonElement; import gov.usgs.earthquake.nshmp.geo.Location; import gov.usgs.earthquake.nshmp.geo.Region; import gov.usgs.earthquake.nshmp.www.ResponseBody; +import gov.usgs.earthquake.nshmp.www.ResponseMetadata; import gov.usgs.earthquake.nshmp.www.Utils; import gov.usgs.earthquake.nshmp.www.Utils.Key; +import gov.usgs.earthquake.nshmp.www.WsVersion; import gov.usgs.earthquake.nshmp.www.gulf.GulfData; import gov.usgs.earthquake.nshmp.www.gulf.GulfData.GulfDataResponse; @@ -42,6 +44,7 @@ public class GulfService { return ResponseBody.<String, MetadataResponse> usage() .name(SERVICE_NAME) .url(url) + .metadata(new ResponseMetadata(WsVersion.appVersions())) .request(url) .response(new MetadataResponse(request)) .build(); @@ -91,6 +94,7 @@ public class GulfService { return ResponseBody.<RequestData, JsonElement> success() .name(SERVICE_NAME) .url(request.getUri().getPath()) + .metadata(new ResponseMetadata(WsVersion.appVersions())) .request(requestData) .response(value) .build(); -- GitLab From a82b4baf191ef2fcd9819b70216fbf9f0d7392f2 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 15:46:13 -0600 Subject: [PATCH 07/18] test --- .gitlab-ci.yml | 1 + Dockerfile | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9e95147..d3c18cd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -126,6 +126,7 @@ workflow: DOCKER_BUILD_ARGS: | BUILD_IMAGE=${DEVOPS_REGISTRY}usgs/centos:latest FROM_IMAGE=${DEVOPS_REGISTRY}usgs/centos:latest + CI_PROJECT_URL=${CI_PROJECT_URL} IMAGE_TAG: ${ENVIRONMENT}-${CI_COMMIT_SHORT_SHA} #### diff --git a/Dockerfile b/Dockerfile index 1f24f62..d8d06e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,6 +35,7 @@ WORKDIR ${builder_workdir} COPY . . RUN ./gradlew assemble \ + && cat src/main/resource/version/* \ && mv ${libs_dir}/*-all.jar ${jar_file} #### -- GitLab From 422c65770ce9ecf96d2738f65c2ad3bd63597c0e Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 15:49:28 -0600 Subject: [PATCH 08/18] test --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d8d06e6..da9561c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,7 @@ WORKDIR ${builder_workdir} COPY . . RUN ./gradlew assemble \ - && cat src/main/resource/version/* \ + && cat src/main/resources/version/* \ && mv ${libs_dir}/*-all.jar ${jar_file} #### -- GitLab From 23b20ff9e2dadb2ee253e72012010c247ae3f336 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 15:55:10 -0600 Subject: [PATCH 09/18] test --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index da9561c..2f33029 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,8 +34,8 @@ WORKDIR ${builder_workdir} COPY . . +RUN env RUN ./gradlew assemble \ - && cat src/main/resources/version/* \ && mv ${libs_dir}/*-all.jar ${jar_file} #### -- GitLab From 400f99130a916f2bcf5df45d06c6bd2826821875 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 15:59:24 -0600 Subject: [PATCH 10/18] test --- .gitlab-ci.yml | 2 +- Dockerfile | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d3c18cd..f32ccb6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -126,7 +126,6 @@ workflow: DOCKER_BUILD_ARGS: | BUILD_IMAGE=${DEVOPS_REGISTRY}usgs/centos:latest FROM_IMAGE=${DEVOPS_REGISTRY}usgs/centos:latest - CI_PROJECT_URL=${CI_PROJECT_URL} IMAGE_TAG: ${ENVIRONMENT}-${CI_COMMIT_SHORT_SHA} #### @@ -154,6 +153,7 @@ Build Image: BUILD_IMAGE=${DEVOPS_REGISTRY}usgs/amazoncorretto:11 FROM_IMAGE=${DEVOPS_REGISTRY}usgs/amazoncorretto:11 ci_job_token=${CI_JOB_TOKEN} + CI_PROJECT_URL=${CI_PROJECT_URL} UPSTREAM_PATH: ghsc/nshmp/nshmp-ws Build Project: diff --git a/Dockerfile b/Dockerfile index 2f33029..35877fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,6 +36,7 @@ COPY . . RUN env RUN ./gradlew assemble \ + && cat src/main/resources/version/* \ && mv ${libs_dir}/*-all.jar ${jar_file} #### -- GitLab From 4cd0ef8c2e4a38390a5d511c0935eb861f897328 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 15:59:46 -0600 Subject: [PATCH 11/18] test --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f32ccb6..34ed0f4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -161,6 +161,7 @@ Build Project: - .java script: - ./gradlew assemble + - cat src/main/resources/version/* Markdown Lint: extends: -- GitLab From 1c5c7a4da26dbc876251bc9165af03357c05f664 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 16:02:59 -0600 Subject: [PATCH 12/18] test --- .gitlab-ci.yml | 2 +- Dockerfile | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 34ed0f4..2de52c9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -153,7 +153,7 @@ Build Image: BUILD_IMAGE=${DEVOPS_REGISTRY}usgs/amazoncorretto:11 FROM_IMAGE=${DEVOPS_REGISTRY}usgs/amazoncorretto:11 ci_job_token=${CI_JOB_TOKEN} - CI_PROJECT_URL=${CI_PROJECT_URL} + project_url=${CI_PROJECT_URL} UPSTREAM_PATH: ghsc/nshmp/nshmp-ws Build Project: diff --git a/Dockerfile b/Dockerfile index 35877fd..5ece7ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,9 +26,11 @@ ARG gitlab_token=null ARG ci_job_token=null ARG jar_file ARG libs_dir +ARG project_url="" ENV GITLAB_TOKEN ${gitlab_token} ENV CI_JOB_TOKEN ${ci_job_token} +ENV CI_PROJECT_URL ${project_url} WORKDIR ${builder_workdir} -- GitLab From 789302db25a5120eb72c48d71a2e7b6da89e6f3c Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 16:13:10 -0600 Subject: [PATCH 13/18] add branch info --- gradle/app-version.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gradle/app-version.gradle b/gradle/app-version.gradle index 026c82f..d747a59 100644 --- a/gradle/app-version.gradle +++ b/gradle/app-version.gradle @@ -6,8 +6,9 @@ tasks.withType(JavaCompile) { new File(versionFile.getParent()).mkdirs() def details = versionDetails() def ciProjectUrl = System.getenv("CI_PROJECT_URL") + def branch = System.getEnv("CI_COMMIT_BRANCH") def versionInfo = [ - branchName: details.branchName, + branchName: branch ? branch : details.branchName, commitDistance: details.commitDistance, gitHash: details.gitHash, gitHashFull: details.gitHashFull, -- GitLab From f5a1a157802d9ca044d4fad37f6f8edbb3b855fd Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 16:13:14 -0600 Subject: [PATCH 14/18] test --- .gitlab-ci.yml | 1 + Dockerfile | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2de52c9..87b316c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -153,6 +153,7 @@ Build Image: BUILD_IMAGE=${DEVOPS_REGISTRY}usgs/amazoncorretto:11 FROM_IMAGE=${DEVOPS_REGISTRY}usgs/amazoncorretto:11 ci_job_token=${CI_JOB_TOKEN} + commit_branch=${CI_COMMIT_BRANCH} project_url=${CI_PROJECT_URL} UPSTREAM_PATH: ghsc/nshmp/nshmp-ws diff --git a/Dockerfile b/Dockerfile index 5ece7ee..d1a11eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,10 +27,12 @@ ARG ci_job_token=null ARG jar_file ARG libs_dir ARG project_url="" +ARG commit_branch="" ENV GITLAB_TOKEN ${gitlab_token} ENV CI_JOB_TOKEN ${ci_job_token} ENV CI_PROJECT_URL ${project_url} +ENV CI_COMMIT_BRANCH ${commit_branch} WORKDIR ${builder_workdir} -- GitLab From 27b4f0ae250a21e8887055127b7e2c3822da1e49 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 16:14:01 -0600 Subject: [PATCH 15/18] fix method call --- gradle/app-version.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/app-version.gradle b/gradle/app-version.gradle index d747a59..98f01e9 100644 --- a/gradle/app-version.gradle +++ b/gradle/app-version.gradle @@ -6,7 +6,7 @@ tasks.withType(JavaCompile) { new File(versionFile.getParent()).mkdirs() def details = versionDetails() def ciProjectUrl = System.getenv("CI_PROJECT_URL") - def branch = System.getEnv("CI_COMMIT_BRANCH") + def branch = System.getenv("CI_COMMIT_BRANCH") def versionInfo = [ branchName: branch ? branch : details.branchName, commitDistance: details.commitDistance, -- GitLab From cf5a58524e3fbc3dfcf7c119d275bc01243b51a7 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 16:17:29 -0600 Subject: [PATCH 16/18] cleanup --- .gitlab-ci.yml | 1 - Dockerfile | 2 -- 2 files changed, 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 87b316c..3557b82 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -162,7 +162,6 @@ Build Project: - .java script: - ./gradlew assemble - - cat src/main/resources/version/* Markdown Lint: extends: diff --git a/Dockerfile b/Dockerfile index d1a11eb..f7bad4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,9 +38,7 @@ WORKDIR ${builder_workdir} COPY . . -RUN env RUN ./gradlew assemble \ - && cat src/main/resources/version/* \ && mv ${libs_dir}/*-all.jar ${jar_file} #### -- GitLab From 9468018e3287ad5f9760fc8467542a689ff3bb64 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 16:21:22 -0600 Subject: [PATCH 17/18] add build args --- .gitlab-ci.yml | 6 +++--- Dockerfile | 14 +++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3557b82..de2734f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -151,10 +151,10 @@ Build Image: variables: DOCKER_BUILD_ARGS: | BUILD_IMAGE=${DEVOPS_REGISTRY}usgs/amazoncorretto:11 + CI_COMMIT_BRANCH=${CI_COMMIT_BRANCH} + CI_JOB_TOKEN=${CI_JOB_TOKEN} + CI_PROJECT_URL=${CI_PROJECT_URL} FROM_IMAGE=${DEVOPS_REGISTRY}usgs/amazoncorretto:11 - ci_job_token=${CI_JOB_TOKEN} - commit_branch=${CI_COMMIT_BRANCH} - project_url=${CI_PROJECT_URL} UPSTREAM_PATH: ghsc/nshmp/nshmp-ws Build Project: diff --git a/Dockerfile b/Dockerfile index f7bad4d..43fa508 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,22 +22,18 @@ ARG jar_file=${libs_dir}/${project}.jar FROM ${BUILD_IMAGE} as builder ARG builder_workdir -ARG gitlab_token=null -ARG ci_job_token=null +ARG GITLAB_TOKEN=null +ARG CI_JOB_TOKEN=null ARG jar_file ARG libs_dir -ARG project_url="" -ARG commit_branch="" - -ENV GITLAB_TOKEN ${gitlab_token} -ENV CI_JOB_TOKEN ${ci_job_token} -ENV CI_PROJECT_URL ${project_url} -ENV CI_COMMIT_BRANCH ${commit_branch} +ARG CI_PROJECT_URL=null +ARG CI_COMMIT_BRANCH=null WORKDIR ${builder_workdir} COPY . . +RUN env RUN ./gradlew assemble \ && mv ${libs_dir}/*-all.jar ${jar_file} -- GitLab From 6b3334527b231d916cc33ab4aab6951222efd3a8 Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Wed, 20 Apr 2022 16:23:23 -0600 Subject: [PATCH 18/18] remove run cmd --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 43fa508..b7b5af9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,7 +33,6 @@ WORKDIR ${builder_workdir} COPY . . -RUN env RUN ./gradlew assemble \ && mv ${libs_dir}/*-all.jar ${jar_file} -- GitLab