diff --git a/scm-packaging/docker/pom.xml b/scm-packaging/docker/pom.xml index c4197a5b00..a120e43bc9 100644 --- a/scm-packaging/docker/pom.xml +++ b/scm-packaging/docker/pom.xml @@ -52,6 +52,28 @@ + + pl.project13.maven + git-commit-id-plugin + 4.0.0 + + + get-git-commit-id + + revision + + initialize + + + + false + ${project.basedir}/../../.git + + ^git.commit.id.abbrev$ + + + + org.apache.maven.plugins maven-resources-plugin diff --git a/scm-packaging/docker/src/main/build/name.groovy b/scm-packaging/docker/src/main/build/name.groovy index b2dbb6cd54..657d26a45a 100644 --- a/scm-packaging/docker/src/main/build/name.groovy +++ b/scm-packaging/docker/src/main/build/name.groovy @@ -22,23 +22,17 @@ * SOFTWARE. */ -import java.text.SimpleDateFormat - def repository = "docker.io/scmmanager/scm-manager" def version = project.version if (version.contains("SNAPSHOT")) { repository = "docker.io/cloudogu/scm-manager" - def commitHash = System.getenv("GIT_COMMIT") - def buildNumber = System.getenv("BUILD_NUMBER") + def snapshotVersion = project.properties.getProperty("git.commit.id.abbrev") - def snapshotVersion - if (commitHash != null && buildNumber != null) { - snapshotVersion = "${commitHash.substring(0,7)}-${buildNumber}" - } else { - def format = new SimpleDateFormat("yyyyMMdd-HHmmss") - snapshotVersion = format.format(new Date()) + def buildNumber = System.getenv("BUILD_NUMBER") + if (buildNumber != null) { + snapshotVersion += "-${buildNumber}" } version = version.replace("SNAPSHOT", snapshotVersion) diff --git a/scm-packaging/helm/pom.xml b/scm-packaging/helm/pom.xml index 7e99047c22..8be77a1b69 100644 --- a/scm-packaging/helm/pom.xml +++ b/scm-packaging/helm/pom.xml @@ -55,6 +55,28 @@ + + pl.project13.maven + git-commit-id-plugin + 4.0.0 + + + get-git-commit-id + + revision + + validate + + + + false + ${project.basedir}/../../.git + + ^git.commit.id.abbrev$ + + + + org.codehaus.gmavenplus gmavenplus-plugin @@ -77,21 +99,8 @@ - + + @@ -139,10 +148,10 @@ true ${project.basedir}/target/chart - ${project.version} + ${docker.tag} + $${docker.tag} false - ${project.version} - https://get.helm.sh/helm-v${helm.version}-${helm.os}-${helm.arch}.tar.gz + https://get.helm.sh/helm-v${helm.version}-${helm.os}-${helm.arch}.${helm.ext} ${deployment.serverId} ${deployment.target}/repository/helm-v2-releases/ diff --git a/scm-packaging/helm/src/main/build/download.groovy b/scm-packaging/helm/src/main/build/download.groovy new file mode 100644 index 0000000000..bb4feeb1e2 --- /dev/null +++ b/scm-packaging/helm/src/main/build/download.groovy @@ -0,0 +1,65 @@ +/** + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +private String getArchitecture() { + String architecture = System.getProperty("os.arch").toLowerCase(Locale.ENGLISH) + + if (architecture.equals("x86_64") || architecture.equals("amd64")) { + return "amd64" + } else if (architecture.equals("x86") || architecture.equals("i386")) { + return "386" + } else if (architecture.contains("arm64")) { + return "arm64" + } else if (architecture.equals("aarch32") || architecture.startsWith("arm")) { + return "arm" + } else if (architecture.contains("ppc64le") || (architecture.contains("ppc64") && System.getProperty("sun.cpu.endian").equals("little"))) { + return "ppc64le" + } + + throw new IllegalStateException("Unsupported architecture: ${architecture}") +} + +private String getExtension() { + String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH) + if (osName.startsWith("windows")) { + return ".zip" + } + return "tar.gz" +} + +private String getOperatingSystem() { + String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH) + if (osName.startsWith("linux")) { + return "linux" + } else if (osName.startsWith("mac") || osName.startsWith("darwin")) { + return "darwin" + } else if (osName.startsWith("windows")) { + return "windows" + } + throw new IllegalStateException("Unsupported operating system: ${osName}") +} + +project.properties.setProperty("helm.os", getOperatingSystem()) +project.properties.setProperty("helm.arch", getArchitecture()) +project.properties.setProperty("helm.ext", getExtension()) diff --git a/scm-packaging/helm/src/main/chart/values.yaml b/scm-packaging/helm/src/main/chart/values.yaml index 9dc2d9db95..89d081e028 100644 --- a/scm-packaging/helm/src/main/chart/values.yaml +++ b/scm-packaging/helm/src/main/chart/values.yaml @@ -29,8 +29,8 @@ # replicaCount: 1 image: - repository: scmmanager/scm-manager - tag: ${project.version} + repository: ${docker.repository} + tag: ${docker.tag} pullPolicy: Always nameOverride: ""