From f3c8cc942cfa3de25c963d9aaef7c466a4a53c34 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Thu, 24 Nov 2022 10:56:16 +0800 Subject: [PATCH 01/10] Report agent version to OAP --- .../core/util/InstanceJsonPropertiesUtil.java | 29 +++++++++++++++++++ apm-sniffer/apm-agent/pom.xml | 24 +++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/util/InstanceJsonPropertiesUtil.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/util/InstanceJsonPropertiesUtil.java index 8be5a794e4..56e0eddd25 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/util/InstanceJsonPropertiesUtil.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/util/InstanceJsonPropertiesUtil.java @@ -20,14 +20,23 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; + +import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Properties; + import org.apache.skywalking.apm.agent.core.conf.Config; +import org.apache.skywalking.apm.agent.core.logging.api.ILog; +import org.apache.skywalking.apm.agent.core.logging.api.LogManager; import org.apache.skywalking.apm.network.common.v3.KeyStringValuePair; import org.apache.skywalking.apm.util.StringUtil; public class InstanceJsonPropertiesUtil { + + private static ILog LOGGER = LogManager.getLogger(InstanceJsonPropertiesUtil.class); private static final Gson GSON = new Gson(); public static List parseProperties() { @@ -45,7 +54,27 @@ public static List parseProperties() { properties.add(KeyStringValuePair.newBuilder().setKey("namespace").setValue(Config.Agent.NAMESPACE).build()); properties.add(KeyStringValuePair.newBuilder().setKey("cluster").setValue(Config.Agent.CLUSTER).build()); + properties.add(KeyStringValuePair.newBuilder().setKey("version").setValue(getAgentVersion()).build()); return properties; } + + public static String getAgentVersion() { + try { + Properties gitProperties = new Properties(); + InputStream inputStream = InstanceJsonPropertiesUtil.class.getClassLoader().getResourceAsStream("skywalking-agent-git.properties"); + gitProperties.load(inputStream); + + String commitIdAbbrev = gitProperties.getProperty("git.commit.id.abbrev"); + String buildTime = gitProperties.getProperty("git.build.time"); + String buildVersion = gitProperties.getProperty("git.build.version"); + String version = buildVersion + "-" + commitIdAbbrev + "-" + buildTime; + + LOGGER.info("SkyWalking agent version: {}", version); + return version; + } catch (IOException e) { + LOGGER.error("Failed to get agent version", e); + return "Unknown"; + } + } } diff --git a/apm-sniffer/apm-agent/pom.xml b/apm-sniffer/apm-agent/pom.xml index 0f0a02b281..e533761005 100644 --- a/apm-sniffer/apm-agent/pom.xml +++ b/apm-sniffer/apm-agent/pom.xml @@ -52,6 +52,30 @@ skywalking-agent + + pl.project13.maven + git-commit-id-plugin + 4.0.5 + + + get-the-git-infos + + revision + + initialize + + + + true + ${project.build.outputDirectory}/skywalking-agent-git.properties + + ^git.build.(time|version)$ + ^git.commit.id.(abbrev|full)$ + + full + yyMMdd + + maven-shade-plugin From 02b7fba7a1c1f6c5ab1d74f0b359fb3a23479798 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Thu, 24 Nov 2022 22:17:42 +0800 Subject: [PATCH 02/10] support build from source code without .git --- .../core/util/InstanceJsonPropertiesUtil.java | 30 +++++++++++-------- apm-sniffer/apm-agent/pom.xml | 1 + 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/util/InstanceJsonPropertiesUtil.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/util/InstanceJsonPropertiesUtil.java index 56e0eddd25..8fd405fe91 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/util/InstanceJsonPropertiesUtil.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/util/InstanceJsonPropertiesUtil.java @@ -36,7 +36,8 @@ public class InstanceJsonPropertiesUtil { - private static ILog LOGGER = LogManager.getLogger(InstanceJsonPropertiesUtil.class); + private static final ILog LOGGER = LogManager.getLogger(InstanceJsonPropertiesUtil.class); + private static final String GIT_PROPERTIES = "skywalking-agent-git.properties"; private static final Gson GSON = new Gson(); public static List parseProperties() { @@ -61,20 +62,25 @@ public static List parseProperties() { public static String getAgentVersion() { try { - Properties gitProperties = new Properties(); - InputStream inputStream = InstanceJsonPropertiesUtil.class.getClassLoader().getResourceAsStream("skywalking-agent-git.properties"); - gitProperties.load(inputStream); + InputStream inStream = InstanceJsonPropertiesUtil.class.getClassLoader() + .getResourceAsStream(GIT_PROPERTIES); + if (inStream != null) { + Properties gitProperties = new Properties(); + gitProperties.load(inStream); + String commitIdAbbrev = gitProperties.getProperty("git.commit.id.abbrev"); + String buildTime = gitProperties.getProperty("git.build.time"); + String buildVersion = gitProperties.getProperty("git.build.version"); + String version = buildVersion + "-" + commitIdAbbrev + "-" + buildTime; - String commitIdAbbrev = gitProperties.getProperty("git.commit.id.abbrev"); - String buildTime = gitProperties.getProperty("git.build.time"); - String buildVersion = gitProperties.getProperty("git.build.version"); - String version = buildVersion + "-" + commitIdAbbrev + "-" + buildTime; - - LOGGER.info("SkyWalking agent version: {}", version); - return version; + LOGGER.info("SkyWalking agent version: {}", version); + return version; + } else { + LOGGER.warn("{} not found, SkyWalking agent version: unknown", GIT_PROPERTIES); + } } catch (IOException e) { LOGGER.error("Failed to get agent version", e); - return "Unknown"; } + + return "UNKNOWN"; } } diff --git a/apm-sniffer/apm-agent/pom.xml b/apm-sniffer/apm-agent/pom.xml index e533761005..0402605bcc 100644 --- a/apm-sniffer/apm-agent/pom.xml +++ b/apm-sniffer/apm-agent/pom.xml @@ -67,6 +67,7 @@ true + false ${project.build.outputDirectory}/skywalking-agent-git.properties ^git.build.(time|version)$ From a9ed1debb26ab0b53af23f837d4d21ebb930045c Mon Sep 17 00:00:00 2001 From: nisiyong Date: Fri, 25 Nov 2022 00:52:09 +0800 Subject: [PATCH 03/10] Update CHANGE.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 76127d2d52..892dcd3f45 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ Release Notes. * Upgrade agent test tools * [Breaking Change] Compatible with 3.x and 4.x RabbitMQ Client, rename `rabbitmq-5.x-plugin` to `rabbitmq-plugin` * Polish JDBC plugins to make DBType accurate +* Support the agent version to report to OAP as an instance attribute #### Documentation From c8e227df348f0f244aab60b4fe03c558b0112128 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sat, 26 Nov 2022 01:13:20 +0800 Subject: [PATCH 04/10] Create static properties when build from source tarball --- CHANGES.md | 2 +- apm-sniffer/apm-agent-core/pom.xml | 27 ++++++++++ .../core/util/InstanceJsonPropertiesUtil.java | 37 +------------- .../apm/agent/core/version/Version.java | 51 +++++++++++++++++++ apm-sniffer/apm-agent/pom.xml | 25 --------- tools/releasing/create_release.sh | 5 ++ 6 files changed, 86 insertions(+), 61 deletions(-) create mode 100644 apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java diff --git a/CHANGES.md b/CHANGES.md index 892dcd3f45..2d45e81d0b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,7 +13,7 @@ Release Notes. * Upgrade agent test tools * [Breaking Change] Compatible with 3.x and 4.x RabbitMQ Client, rename `rabbitmq-5.x-plugin` to `rabbitmq-plugin` * Polish JDBC plugins to make DBType accurate -* Support the agent version to report to OAP as an instance attribute +* Report the agent version to OAP as an instance attribute #### Documentation diff --git a/apm-sniffer/apm-agent-core/pom.xml b/apm-sniffer/apm-agent-core/pom.xml index 65a2689120..9d641888fa 100644 --- a/apm-sniffer/apm-agent-core/pom.xml +++ b/apm-sniffer/apm-agent-core/pom.xml @@ -33,10 +33,12 @@ UTF-8 + ${generateGitPropertiesFilename} 30.1.1-jre 2.6.0 2.0.7.Final 1.4.1.Final + 4.9.10 com.google ${shade.package}.${shade.com.google.source} io.grpc @@ -171,6 +173,31 @@ + + pl.project13.maven + git-commit-id-plugin + ${git-commit-id-plugin.version} + + + get-the-git-infos + + revision + + initialize + + + + true + false + ${generateGitPropertiesFilename} + + ^git.build.(time|version)$ + ^git.commit.id.(abbrev|full)$ + + full + yyMMdd + + maven-shade-plugin diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/util/InstanceJsonPropertiesUtil.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/util/InstanceJsonPropertiesUtil.java index 8fd405fe91..0960caa596 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/util/InstanceJsonPropertiesUtil.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/util/InstanceJsonPropertiesUtil.java @@ -20,24 +20,15 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; - -import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Properties; - import org.apache.skywalking.apm.agent.core.conf.Config; -import org.apache.skywalking.apm.agent.core.logging.api.ILog; -import org.apache.skywalking.apm.agent.core.logging.api.LogManager; +import org.apache.skywalking.apm.agent.core.version.Version; import org.apache.skywalking.apm.network.common.v3.KeyStringValuePair; import org.apache.skywalking.apm.util.StringUtil; public class InstanceJsonPropertiesUtil { - - private static final ILog LOGGER = LogManager.getLogger(InstanceJsonPropertiesUtil.class); - private static final String GIT_PROPERTIES = "skywalking-agent-git.properties"; private static final Gson GSON = new Gson(); public static List parseProperties() { @@ -55,32 +46,8 @@ public static List parseProperties() { properties.add(KeyStringValuePair.newBuilder().setKey("namespace").setValue(Config.Agent.NAMESPACE).build()); properties.add(KeyStringValuePair.newBuilder().setKey("cluster").setValue(Config.Agent.CLUSTER).build()); - properties.add(KeyStringValuePair.newBuilder().setKey("version").setValue(getAgentVersion()).build()); + properties.add(KeyStringValuePair.newBuilder().setKey("version").setValue(Version.CURRENT.toString()).build()); return properties; } - - public static String getAgentVersion() { - try { - InputStream inStream = InstanceJsonPropertiesUtil.class.getClassLoader() - .getResourceAsStream(GIT_PROPERTIES); - if (inStream != null) { - Properties gitProperties = new Properties(); - gitProperties.load(inStream); - String commitIdAbbrev = gitProperties.getProperty("git.commit.id.abbrev"); - String buildTime = gitProperties.getProperty("git.build.time"); - String buildVersion = gitProperties.getProperty("git.build.version"); - String version = buildVersion + "-" + commitIdAbbrev + "-" + buildTime; - - LOGGER.info("SkyWalking agent version: {}", version); - return version; - } else { - LOGGER.warn("{} not found, SkyWalking agent version: unknown", GIT_PROPERTIES); - } - } catch (IOException e) { - LOGGER.error("Failed to get agent version", e); - } - - return "UNKNOWN"; - } } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java new file mode 100644 index 0000000000..83156a3d25 --- /dev/null +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.agent.core.version; + +import lombok.Getter; + +import java.io.IOException; +import java.util.Properties; + +@Getter +public enum Version { + CURRENT; + + private static final String VERSION_FILE_NAME = "skywalking-agent-version.properties"; + private final String buildVersion; + private final String commitIdAbbrev; + private final String buildTime; + + Version() { + try { + Properties properties = new Properties(); + properties.load(Version.class.getClassLoader().getResourceAsStream(VERSION_FILE_NAME)); + buildVersion = properties.getProperty("git.build.version"); + commitIdAbbrev = properties.getProperty("git.commit.id.abbrev"); + buildTime = properties.getProperty("git.build.time"); + } catch (IOException e) { + throw new ExceptionInInitializerError(e); + } + } + + @Override + public String toString() { + return String.format("%s-%s-%s", buildVersion, commitIdAbbrev, buildTime); + } +} diff --git a/apm-sniffer/apm-agent/pom.xml b/apm-sniffer/apm-agent/pom.xml index 0402605bcc..0f0a02b281 100644 --- a/apm-sniffer/apm-agent/pom.xml +++ b/apm-sniffer/apm-agent/pom.xml @@ -52,31 +52,6 @@ skywalking-agent - - pl.project13.maven - git-commit-id-plugin - 4.0.5 - - - get-the-git-infos - - revision - - initialize - - - - true - false - ${project.build.outputDirectory}/skywalking-agent-git.properties - - ^git.build.(time|version)$ - ^git.commit.id.(abbrev|full)$ - - full - yyMMdd - - maven-shade-plugin diff --git a/tools/releasing/create_release.sh b/tools/releasing/create_release.sh index ee78728de8..ea293b1d0c 100755 --- a/tools/releasing/create_release.sh +++ b/tools/releasing/create_release.sh @@ -59,6 +59,11 @@ git checkout ${TAG_NAME} git submodule init git submodule update +# Generate a static version.properties and override the template when releasing source tar +# because after that there is no Git information anymore. +./mvnw -pl apm-sniffer/apm-agent-core initialize \ + -DgenerateGitPropertiesFilename="$(pwd)/apm-sniffer/apm-agent-core/src/main/resources/version.properties" + cd .. # Build source code tar tar czf ${PRODUCT_NAME}-src.tgz \ From 6593d172f5aad4293c16a851b73f133c8715fc37 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sat, 26 Nov 2022 23:17:08 +0800 Subject: [PATCH 05/10] Add version log and fix compile faield --- apm-sniffer/apm-agent-core/pom.xml | 2 +- .../apm/agent/core/version/Version.java | 16 ++++++++++++++-- tools/releasing/create_release.sh | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/apm-sniffer/apm-agent-core/pom.xml b/apm-sniffer/apm-agent-core/pom.xml index 9d641888fa..7df34ea9f8 100644 --- a/apm-sniffer/apm-agent-core/pom.xml +++ b/apm-sniffer/apm-agent-core/pom.xml @@ -33,7 +33,7 @@ UTF-8 - ${generateGitPropertiesFilename} + ${project.build.outputDirectory}/skywalking-agent-version.properties 30.1.1-jre 2.6.0 2.0.7.Final diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java index 83156a3d25..b7116cbdb5 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java @@ -19,14 +19,18 @@ package org.apache.skywalking.apm.agent.core.version; import lombok.Getter; +import org.apache.skywalking.apm.agent.core.logging.api.ILog; +import org.apache.skywalking.apm.agent.core.logging.api.LogManager; import java.io.IOException; +import java.io.InputStream; import java.util.Properties; @Getter public enum Version { CURRENT; + private static final ILog LOGGER = LogManager.getLogger(Version.class); private static final String VERSION_FILE_NAME = "skywalking-agent-version.properties"; private final String buildVersion; private final String commitIdAbbrev; @@ -34,16 +38,24 @@ public enum Version { Version() { try { + InputStream inputStream = Version.class.getClassLoader().getResourceAsStream(VERSION_FILE_NAME); + if (inputStream == null) { + throw new IOException("Can't find " + VERSION_FILE_NAME); + } Properties properties = new Properties(); - properties.load(Version.class.getClassLoader().getResourceAsStream(VERSION_FILE_NAME)); + properties.load(inputStream); buildVersion = properties.getProperty("git.build.version"); commitIdAbbrev = properties.getProperty("git.commit.id.abbrev"); buildTime = properties.getProperty("git.build.time"); - } catch (IOException e) { + } catch (Exception e) { throw new ExceptionInInitializerError(e); } } + static { + LOGGER.info("SkyWalking agent version: {}", CURRENT); + } + @Override public String toString() { return String.format("%s-%s-%s", buildVersion, commitIdAbbrev, buildTime); diff --git a/tools/releasing/create_release.sh b/tools/releasing/create_release.sh index ea293b1d0c..3afd97133f 100755 --- a/tools/releasing/create_release.sh +++ b/tools/releasing/create_release.sh @@ -59,10 +59,10 @@ git checkout ${TAG_NAME} git submodule init git submodule update -# Generate a static version.properties and override the template when releasing source tar +# Generate a static skywalking-agent-version.properties and override the template when releasing source tar # because after that there is no Git information anymore. ./mvnw -pl apm-sniffer/apm-agent-core initialize \ - -DgenerateGitPropertiesFilename="$(pwd)/apm-sniffer/apm-agent-core/src/main/resources/version.properties" + -DgenerateGitPropertiesFilename="$(pwd)/apm-sniffer/apm-agent-core/src/main/resources/skywalking-agent-version.properties" cd .. # Build source code tar From 5c280330b0e0214b6a57b19886c42b61f78492dc Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sun, 27 Nov 2022 00:09:09 +0800 Subject: [PATCH 06/10] checkstyle plugin exclude skywalking-agent-version.properties --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d802424a41..c58790f429 100755 --- a/pom.xml +++ b/pom.xml @@ -402,7 +402,8 @@ **/.asf.yaml, - **/.github/** + **/.github/**, + **/skywalking-agent-version.properties **/target/generated-test-sources/**, From 1950ce41d68104a3fe7ec6c8fce8b8cca278360d Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sun, 27 Nov 2022 13:58:37 +0800 Subject: [PATCH 07/10] Remove `git.build.time` when build from source tarball --- apm-sniffer/apm-agent-core/pom.xml | 7 ++++--- .../apache/skywalking/apm/agent/core/version/Version.java | 5 ++++- tools/releasing/create_release.sh | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/apm-sniffer/apm-agent-core/pom.xml b/apm-sniffer/apm-agent-core/pom.xml index 7df34ea9f8..5a1f75bca8 100644 --- a/apm-sniffer/apm-agent-core/pom.xml +++ b/apm-sniffer/apm-agent-core/pom.xml @@ -187,15 +187,16 @@ - true false + true ${generateGitPropertiesFilename} + yyyyMMddHHmmss + UTC + full ^git.build.(time|version)$ ^git.commit.id.(abbrev|full)$ - full - yyMMdd diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java index b7116cbdb5..eb6670f101 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java @@ -21,6 +21,7 @@ import lombok.Getter; import org.apache.skywalking.apm.agent.core.logging.api.ILog; import org.apache.skywalking.apm.agent.core.logging.api.LogManager; +import org.apache.skywalking.apm.util.StringUtil; import java.io.IOException; import java.io.InputStream; @@ -58,6 +59,8 @@ public enum Version { @Override public String toString() { - return String.format("%s-%s-%s", buildVersion, commitIdAbbrev, buildTime); + return StringUtil.isEmpty(buildTime) ? + String.format("%s-%s", buildVersion, commitIdAbbrev) : + String.format("%s-%s-%s", buildVersion, commitIdAbbrev, buildTime); } } diff --git a/tools/releasing/create_release.sh b/tools/releasing/create_release.sh index 3afd97133f..345d809cae 100755 --- a/tools/releasing/create_release.sh +++ b/tools/releasing/create_release.sh @@ -61,8 +61,10 @@ git submodule update # Generate a static skywalking-agent-version.properties and override the template when releasing source tar # because after that there is no Git information anymore. -./mvnw -pl apm-sniffer/apm-agent-core initialize \ - -DgenerateGitPropertiesFilename="$(pwd)/apm-sniffer/apm-agent-core/src/main/resources/skywalking-agent-version.properties" +GIT_PROPERTIES_PATH=$(pwd)/apm-sniffer/apm-agent-core/src/main/resources/skywalking-agent-version.properties +./mvnw -q -pl apm-sniffer/apm-agent-core initialize -DgenerateGitPropertiesFilename="${GIT_PROPERTIES_PATH}" +# Remove this line, because the `git.build.time` could not be overridden. +sed '/git.build.time/d' ${GIT_PROPERTIES_PATH} > ${GIT_PROPERTIES_PATH} cd .. # Build source code tar From 845a1a1e13d4f5c6b5d4192e4246682eb82fedc1 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sun, 27 Nov 2022 14:36:59 +0800 Subject: [PATCH 08/10] Fix sed --- tools/releasing/create_release.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/releasing/create_release.sh b/tools/releasing/create_release.sh index 345d809cae..dd94e7862c 100755 --- a/tools/releasing/create_release.sh +++ b/tools/releasing/create_release.sh @@ -62,9 +62,10 @@ git submodule update # Generate a static skywalking-agent-version.properties and override the template when releasing source tar # because after that there is no Git information anymore. GIT_PROPERTIES_PATH=$(pwd)/apm-sniffer/apm-agent-core/src/main/resources/skywalking-agent-version.properties -./mvnw -q -pl apm-sniffer/apm-agent-core initialize -DgenerateGitPropertiesFilename="${GIT_PROPERTIES_PATH}" +./mvnw -q -pl apm-sniffer/apm-agent-core initialize -DgenerateGitPropertiesFilename="${GIT_PROPERTIES_PATH}.tmp" # Remove this line, because the `git.build.time` could not be overridden. -sed '/git.build.time/d' ${GIT_PROPERTIES_PATH} > ${GIT_PROPERTIES_PATH} +sed '/git.build.time/d' ${GIT_PROPERTIES_PATH}.tmp > ${GIT_PROPERTIES_PATH} +rm -f ${GIT_PROPERTIES_PATH}.tmp cd .. # Build source code tar From 17f44094fe27cf901bd8fa275dbdd7d42f0060e8 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sun, 27 Nov 2022 23:27:01 +0800 Subject: [PATCH 09/10] Remove `git.build.time` --- apm-sniffer/apm-agent-core/pom.xml | 4 +--- .../apache/skywalking/apm/agent/core/version/Version.java | 7 +------ tools/releasing/create_release.sh | 7 ++----- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/apm-sniffer/apm-agent-core/pom.xml b/apm-sniffer/apm-agent-core/pom.xml index 5a1f75bca8..07fc67f556 100644 --- a/apm-sniffer/apm-agent-core/pom.xml +++ b/apm-sniffer/apm-agent-core/pom.xml @@ -190,11 +190,9 @@ false true ${generateGitPropertiesFilename} - yyyyMMddHHmmss - UTC full - ^git.build.(time|version)$ + git.build.version ^git.commit.id.(abbrev|full)$ diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java index eb6670f101..da2cf00c17 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/version/Version.java @@ -21,7 +21,6 @@ import lombok.Getter; import org.apache.skywalking.apm.agent.core.logging.api.ILog; import org.apache.skywalking.apm.agent.core.logging.api.LogManager; -import org.apache.skywalking.apm.util.StringUtil; import java.io.IOException; import java.io.InputStream; @@ -35,7 +34,6 @@ public enum Version { private static final String VERSION_FILE_NAME = "skywalking-agent-version.properties"; private final String buildVersion; private final String commitIdAbbrev; - private final String buildTime; Version() { try { @@ -47,7 +45,6 @@ public enum Version { properties.load(inputStream); buildVersion = properties.getProperty("git.build.version"); commitIdAbbrev = properties.getProperty("git.commit.id.abbrev"); - buildTime = properties.getProperty("git.build.time"); } catch (Exception e) { throw new ExceptionInInitializerError(e); } @@ -59,8 +56,6 @@ public enum Version { @Override public String toString() { - return StringUtil.isEmpty(buildTime) ? - String.format("%s-%s", buildVersion, commitIdAbbrev) : - String.format("%s-%s-%s", buildVersion, commitIdAbbrev, buildTime); + return String.format("%s-%s", buildVersion, commitIdAbbrev); } } diff --git a/tools/releasing/create_release.sh b/tools/releasing/create_release.sh index dd94e7862c..98cedccc01 100755 --- a/tools/releasing/create_release.sh +++ b/tools/releasing/create_release.sh @@ -61,11 +61,8 @@ git submodule update # Generate a static skywalking-agent-version.properties and override the template when releasing source tar # because after that there is no Git information anymore. -GIT_PROPERTIES_PATH=$(pwd)/apm-sniffer/apm-agent-core/src/main/resources/skywalking-agent-version.properties -./mvnw -q -pl apm-sniffer/apm-agent-core initialize -DgenerateGitPropertiesFilename="${GIT_PROPERTIES_PATH}.tmp" -# Remove this line, because the `git.build.time` could not be overridden. -sed '/git.build.time/d' ${GIT_PROPERTIES_PATH}.tmp > ${GIT_PROPERTIES_PATH} -rm -f ${GIT_PROPERTIES_PATH}.tmp +./mvnw -q -pl apm-sniffer/apm-agent-core initialize \ + -DgenerateGitPropertiesFilename="$(pwd)/apm-sniffer/apm-agent-core/src/main/resources/skywalking-agent-version.properties" cd .. # Build source code tar From ab04dbf033577ccc8dfcbbf93b152b663a2bcf75 Mon Sep 17 00:00:00 2001 From: nisiyong Date: Sun, 27 Nov 2022 23:47:12 +0800 Subject: [PATCH 10/10] Fix CI --- test/e2e/case/expected/service-instance.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/e2e/case/expected/service-instance.yml b/test/e2e/case/expected/service-instance.yml index 59b8e014b8..60c02ef761 100644 --- a/test/e2e/case/expected/service-instance.yml +++ b/test/e2e/case/expected/service-instance.yml @@ -36,6 +36,8 @@ value: '{{ notEmpty .value }}' - name: ipv4s value: {{ notEmpty .value }} + - name: version + value: {{ notEmpty .value }} {{- end }} language: JAVA instanceuuid: {{ b64enc "e2e-service-provider" }}.1_{{ b64enc "provider1" }}