align docker and helm versions

This commit is contained in:
Sebastian Sdorra
2020-05-26 08:17:22 +02:00
parent df1c8f5084
commit bb8b8bc4ce
5 changed files with 120 additions and 30 deletions

View File

@@ -52,6 +52,28 @@
<build>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.0</version>
<executions>
<execution>
<id>get-git-commit-id</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<skipPoms>false</skipPoms>
<dotGitDirectory>${project.basedir}/../../.git</dotGitDirectory>
<includeOnlyProperties>
<includeOnlyProperty>^git.commit.id.abbrev$</includeOnlyProperty>
</includeOnlyProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>

View File

@@ -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)

View File

@@ -55,6 +55,28 @@
</configuration>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.0</version>
<executions>
<execution>
<id>get-git-commit-id</id>
<goals>
<goal>revision</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
<configuration>
<skipPoms>false</skipPoms>
<dotGitDirectory>${project.basedir}/../../.git</dotGitDirectory>
<includeOnlyProperties>
<includeOnlyProperty>^git.commit.id.abbrev$</includeOnlyProperty>
</includeOnlyProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
@@ -77,21 +99,8 @@
</goals>
<configuration>
<scripts>
<script>
<![CDATA[
String os = System.getProperty("os.name").toLowerCase()
if (os.startsWith("mac")){
os = "darwin"
}
project.properties.setProperty('helm.os', os)
String arch = System.getProperty("os.arch").toLowerCase()
if ("x86_64".equals(arch)) {
arch = "amd64"
}
project.properties.setProperty('helm.arch', arch)
]]>
</script>
<script>${project.basedir}/src/main/build/download.groovy</script>
<script>${project.basedir}/../docker/src/main/build/name.groovy</script>
</scripts>
</configuration>
</execution>
@@ -139,10 +148,10 @@
<extensions>true</extensions>
<configuration>
<chartDirectory>${project.basedir}/target/chart</chartDirectory>
<chartVersion>${project.version}</chartVersion>
<chartVersion>${docker.tag}</chartVersion>
<appVersion>$${docker.tag}</appVersion>
<autoDetectLocalHelmBinary>false</autoDetectLocalHelmBinary>
<appVersion>${project.version}</appVersion>
<helmDownloadUrl>https://get.helm.sh/helm-v${helm.version}-${helm.os}-${helm.arch}.tar.gz</helmDownloadUrl>
<helmDownloadUrl>https://get.helm.sh/helm-v${helm.version}-${helm.os}-${helm.arch}.${helm.ext}</helmDownloadUrl>
<uploadRepoStable>
<name>${deployment.serverId}</name>
<url>${deployment.target}/repository/helm-v2-releases/</url>

View File

@@ -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())

View File

@@ -29,8 +29,8 @@
# replicaCount: 1
image:
repository: scmmanager/scm-manager
tag: ${project.version}
repository: ${docker.repository}
tag: ${docker.tag}
pullPolicy: Always
nameOverride: ""