From 1cb245c43ad8882b1f64b51cf82303e64974b385 Mon Sep 17 00:00:00 2001 From: farthinder Date: Tue, 23 Apr 2024 15:31:00 +0200 Subject: [PATCH] 2.3.17 - JSM minor feature add (#38) * JsmContainer.groovy * Added isAppAppUploadEnabled * enableAppUpload now checks if the container exists, and then if the expected env is present pom.xml * Bumped to 2.3.17 * JsmContainer.groovy * Added isAppAppUploadEnabled * enableAppUpload now checks if the container exists, and then if the expected env is present pom.xml * Bumped to 2.3.17 --- examples/Basic JSM Setup.groovy | 2 +- pom.xml | 2 +- .../container/impl/JsmContainer.groovy | 40 ++++++++++++++----- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/examples/Basic JSM Setup.groovy b/examples/Basic JSM Setup.groovy index 8856081..47c00e8 100644 --- a/examples/Basic JSM Setup.groovy +++ b/examples/Basic JSM Setup.groovy @@ -1,5 +1,5 @@ @GrabResolver(name = 'github', root = 'https://github.com/eficode/DevStack/raw/packages/repository/') -@Grab(group = 'com.eficode', module = 'devstack-standalone', version = '2.3.13') +@Grab(group = 'com.eficode', module = 'devstack-standalone', version = '2.3.14') @Grab(group='org.slf4j', module='slf4j-simple', version='1.7.36', scope='test') @GrabConfig(systemClassLoader=true, initContextClassLoader=true) diff --git a/pom.xml b/pom.xml index fca3286..96d45e5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eficode devstack - 2.3.15 + 2.3.17 jar DevStack diff --git a/src/main/groovy/com/eficode/devstack/container/impl/JsmContainer.groovy b/src/main/groovy/com/eficode/devstack/container/impl/JsmContainer.groovy index f3cb5eb..6b88764 100644 --- a/src/main/groovy/com/eficode/devstack/container/impl/JsmContainer.groovy +++ b/src/main/groovy/com/eficode/devstack/container/impl/JsmContainer.groovy @@ -23,7 +23,8 @@ class JsmContainer implements Container { long jvmMaxRam = 6000 private String debugPort //Contains the port used for JVM debug - ArrayList jvmSupportRecommendedArgs = [] //Used for setting application properties: https://confluence.atlassian.com/adminjiraserver/setting-properties-and-options-on-startup-938847831.html + ArrayList jvmSupportRecommendedArgs = [] + //Used for setting application properties: https://confluence.atlassian.com/adminjiraserver/setting-properties-and-options-on-startup-938847831.html JsmContainer(String dockerHost = "", String dockerCertPath = "") { if (dockerHost && dockerCertPath) { @@ -37,6 +38,7 @@ class JsmContainer implements Container { */ void enableJvmDebug(String portNr = "5005") { + assert !created: "Error, cant enable JVM Debug for a container that has already been created" debugPort = portNr jvmSupportRecommendedArgs += ["-Xdebug", "-Xrunjdwp:transport=dt_socket,address=*:${debugPort},server=y,suspend=n"] @@ -47,10 +49,28 @@ class JsmContainer implements Container { * See: https://jira.atlassian.com/browse/JRASERVER-77129 */ void enableAppUpload() { + + log.info("Enabling upload of Custom JIRA Apps") + if (appAppUploadEnabled){ + log.debug("\tApp upload is already enabled") + } assert !created: "Error, cant enable App Upload for a container that has already been created" jvmSupportRecommendedArgs += ["-Dupm.plugin.upload.enabled=true"] } + /** + * Checks if App Upload is enabled for a container that has been created + * @return + */ + boolean isAppAppUploadEnabled() { + + if (!created) { + return false + } + return inspectContainer()?.getConfig()?.env?.toString()?.contains("-Dupm.plugin.upload.enabled=true") ?: false + + } + /** * Gets the latest version number from Atlassian Marketplace * @return ex: 5.6.0 @@ -116,7 +136,7 @@ class JsmContainer implements Container { } if (jvmSupportRecommendedArgs) { - containerCreateRequest.env.add("JVM_SUPPORT_RECOMMENDED_ARGS=" + jvmSupportRecommendedArgs.join(" ")) + containerCreateRequest.env.add("JVM_SUPPORT_RECOMMENDED_ARGS=" + jvmSupportRecommendedArgs.join(" ")) } return containerCreateRequest @@ -129,7 +149,7 @@ class JsmContainer implements Container { * @return */ MountPoint getJiraHomeMountPoint() { - return getMounts().find {it.destination == "/var/atlassian/application-data/jira"} + return getMounts().find { it.destination == "/var/atlassian/application-data/jira" } } @@ -145,7 +165,7 @@ class JsmContainer implements Container { stopContainer() snapshotName = snapshotName ?: shortId + "-clone" - boolean success = dockerClient.overwriteVolume(snapshotName, jiraHomeMountPoint.name) + boolean success = dockerClient.overwriteVolume(snapshotName, jiraHomeMountPoint.name) if (wasRunning) { startContainer() } @@ -166,9 +186,9 @@ class JsmContainer implements Container { if (volumes.size() == 1) { return volumes.first() - }else if (volumes.isEmpty()) { + } else if (volumes.isEmpty()) { return null - }else { + } else { throw new InputMismatchException("Error finding snapshot volume:" + snapshotName) } @@ -190,7 +210,7 @@ class JsmContainer implements Container { snapshotName = snapshotName ?: shortId + "-clone" ArrayList existingVolumes = dockerClient.getVolumesWithName(snapshotName) - existingVolumes.each {existingVolume -> + existingVolumes.each { existingVolume -> log.debug("\tRemoving existing snapshot volume:" + existingVolume.name) dockerClient.manageVolume.rmVolume(existingVolume.name) } @@ -208,7 +228,7 @@ class JsmContainer implements Container { * Clone JIRA home volume * Container must be stopped * @param newVolumeName must be unique - * @param labels, optional labels to add to the new volume + * @param labels , optional labels to add to the new volume * @return */ Volume cloneJiraHome(String newVolumeName = "", Map labels = null) { @@ -216,8 +236,8 @@ class JsmContainer implements Container { newVolumeName = newVolumeName ?: shortId + "-clone" labels = labels ?: [ - srcContainerId : getId(), - created : System.currentTimeSeconds() + srcContainerId: getId(), + created : System.currentTimeSeconds() ] as Map Volume newVolume = dockerClient.cloneVolume(jiraHomeMountPoint.name, newVolumeName, labels)