Skip to content

Commit 1cb245c

Browse files
authored
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
1 parent 58d337a commit 1cb245c

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

examples/Basic JSM Setup.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@GrabResolver(name = 'github', root = 'https://github.com/eficode/DevStack/raw/packages/repository/')
2-
@Grab(group = 'com.eficode', module = 'devstack-standalone', version = '2.3.13')
2+
@Grab(group = 'com.eficode', module = 'devstack-standalone', version = '2.3.14')
33
@Grab(group='org.slf4j', module='slf4j-simple', version='1.7.36', scope='test')
44
@GrabConfig(systemClassLoader=true, initContextClassLoader=true)
55

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.eficode</groupId>
88
<artifactId>devstack</artifactId>
9-
<version>2.3.15</version>
9+
<version>2.3.17</version>
1010
<packaging>jar</packaging>
1111

1212
<name>DevStack</name>

src/main/groovy/com/eficode/devstack/container/impl/JsmContainer.groovy

+30-10
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class JsmContainer implements Container {
2323
long jvmMaxRam = 6000
2424

2525
private String debugPort //Contains the port used for JVM debug
26-
ArrayList<String> jvmSupportRecommendedArgs = [] //Used for setting application properties: https://confluence.atlassian.com/adminjiraserver/setting-properties-and-options-on-startup-938847831.html
26+
ArrayList<String> jvmSupportRecommendedArgs = []
27+
//Used for setting application properties: https://confluence.atlassian.com/adminjiraserver/setting-properties-and-options-on-startup-938847831.html
2728

2829
JsmContainer(String dockerHost = "", String dockerCertPath = "") {
2930
if (dockerHost && dockerCertPath) {
@@ -37,6 +38,7 @@ class JsmContainer implements Container {
3738
*/
3839
void enableJvmDebug(String portNr = "5005") {
3940

41+
4042
assert !created: "Error, cant enable JVM Debug for a container that has already been created"
4143
debugPort = portNr
4244
jvmSupportRecommendedArgs += ["-Xdebug", "-Xrunjdwp:transport=dt_socket,address=*:${debugPort},server=y,suspend=n"]
@@ -47,10 +49,28 @@ class JsmContainer implements Container {
4749
* See: https://jira.atlassian.com/browse/JRASERVER-77129
4850
*/
4951
void enableAppUpload() {
52+
53+
log.info("Enabling upload of Custom JIRA Apps")
54+
if (appAppUploadEnabled){
55+
log.debug("\tApp upload is already enabled")
56+
}
5057
assert !created: "Error, cant enable App Upload for a container that has already been created"
5158
jvmSupportRecommendedArgs += ["-Dupm.plugin.upload.enabled=true"]
5259
}
5360

61+
/**
62+
* Checks if App Upload is enabled for a container that has been created
63+
* @return
64+
*/
65+
boolean isAppAppUploadEnabled() {
66+
67+
if (!created) {
68+
return false
69+
}
70+
return inspectContainer()?.getConfig()?.env?.toString()?.contains("-Dupm.plugin.upload.enabled=true") ?: false
71+
72+
}
73+
5474
/**
5575
* Gets the latest version number from Atlassian Marketplace
5676
* @return ex: 5.6.0
@@ -116,7 +136,7 @@ class JsmContainer implements Container {
116136
}
117137

118138
if (jvmSupportRecommendedArgs) {
119-
containerCreateRequest.env.add("JVM_SUPPORT_RECOMMENDED_ARGS=" + jvmSupportRecommendedArgs.join(" "))
139+
containerCreateRequest.env.add("JVM_SUPPORT_RECOMMENDED_ARGS=" + jvmSupportRecommendedArgs.join(" "))
120140
}
121141

122142
return containerCreateRequest
@@ -129,7 +149,7 @@ class JsmContainer implements Container {
129149
* @return
130150
*/
131151
MountPoint getJiraHomeMountPoint() {
132-
return getMounts().find {it.destination == "/var/atlassian/application-data/jira"}
152+
return getMounts().find { it.destination == "/var/atlassian/application-data/jira" }
133153
}
134154

135155

@@ -145,7 +165,7 @@ class JsmContainer implements Container {
145165
stopContainer()
146166
snapshotName = snapshotName ?: shortId + "-clone"
147167

148-
boolean success = dockerClient.overwriteVolume(snapshotName, jiraHomeMountPoint.name)
168+
boolean success = dockerClient.overwriteVolume(snapshotName, jiraHomeMountPoint.name)
149169
if (wasRunning) {
150170
startContainer()
151171
}
@@ -166,9 +186,9 @@ class JsmContainer implements Container {
166186

167187
if (volumes.size() == 1) {
168188
return volumes.first()
169-
}else if (volumes.isEmpty()) {
189+
} else if (volumes.isEmpty()) {
170190
return null
171-
}else {
191+
} else {
172192
throw new InputMismatchException("Error finding snapshot volume:" + snapshotName)
173193
}
174194

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

192212
ArrayList<Volume> existingVolumes = dockerClient.getVolumesWithName(snapshotName)
193-
existingVolumes.each {existingVolume ->
213+
existingVolumes.each { existingVolume ->
194214
log.debug("\tRemoving existing snapshot volume:" + existingVolume.name)
195215
dockerClient.manageVolume.rmVolume(existingVolume.name)
196216
}
@@ -208,16 +228,16 @@ class JsmContainer implements Container {
208228
* Clone JIRA home volume
209229
* Container must be stopped
210230
* @param newVolumeName must be unique
211-
* @param labels, optional labels to add to the new volume
231+
* @param labels , optional labels to add to the new volume
212232
* @return
213233
*/
214234
Volume cloneJiraHome(String newVolumeName = "", Map<String, Object> labels = null) {
215235

216236
newVolumeName = newVolumeName ?: shortId + "-clone"
217237

218238
labels = labels ?: [
219-
srcContainerId : getId(),
220-
created : System.currentTimeSeconds()
239+
srcContainerId: getId(),
240+
created : System.currentTimeSeconds()
221241
] as Map
222242

223243
Volume newVolume = dockerClient.cloneVolume(jiraHomeMountPoint.name, newVolumeName, labels)

0 commit comments

Comments
 (0)