Skip to content

Commit

Permalink
2.3.17 - JSM minor feature add (#38)
Browse files Browse the repository at this point in the history

* 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
  • Loading branch information
farthinder authored Apr 23, 2024
1 parent 58d337a commit 1cb245c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/Basic JSM Setup.groovy
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.eficode</groupId>
<artifactId>devstack</artifactId>
<version>2.3.15</version>
<version>2.3.17</version>
<packaging>jar</packaging>

<name>DevStack</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class JsmContainer implements Container {
long jvmMaxRam = 6000

private String debugPort //Contains the port used for JVM debug
ArrayList<String> jvmSupportRecommendedArgs = [] //Used for setting application properties: https://confluence.atlassian.com/adminjiraserver/setting-properties-and-options-on-startup-938847831.html
ArrayList<String> 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) {
Expand All @@ -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"]
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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" }
}


Expand All @@ -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()
}
Expand All @@ -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)
}

Expand All @@ -190,7 +210,7 @@ class JsmContainer implements Container {
snapshotName = snapshotName ?: shortId + "-clone"

ArrayList<Volume> existingVolumes = dockerClient.getVolumesWithName(snapshotName)
existingVolumes.each {existingVolume ->
existingVolumes.each { existingVolume ->
log.debug("\tRemoving existing snapshot volume:" + existingVolume.name)
dockerClient.manageVolume.rmVolume(existingVolume.name)
}
Expand All @@ -208,16 +228,16 @@ 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<String, Object> labels = null) {

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)
Expand Down

0 comments on commit 1cb245c

Please sign in to comment.