Skip to content

Commit 83285b5

Browse files
authored
2.3.3 Bumped docker-client and added jsmContainer.enableJvmDebug() (#23)
* pom.xml Bumped to 2.3.2 Bumped DockerClient to 2023-05-07T23-22-00 * pom.xml * Bumped to 2.3.3 JsmContainer.groovy * Added enableJvmDebug()
1 parent c42e20c commit 83285b5

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
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.2-SNAPSHOT</version>
9+
<version>2.3.3-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<name>DevStack</name>

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

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,23 @@ class JsmContainer implements Container {
2222
String containerImageTag = "latest"
2323
long jvmMaxRam = 6000
2424

25+
private String debugPort //Contains the port used for JVM debug
26+
2527
JsmContainer(String dockerHost = "", String dockerCertPath = "") {
2628
if (dockerHost && dockerCertPath) {
2729
assert setupSecureRemoteConnection(dockerHost, dockerCertPath): "Error setting up secure remote docker connection"
2830
}
2931
}
3032

33+
/**
34+
* Enables JVM debug of JIRA for port portNr
35+
* @param portNr
36+
*/
37+
void enableJvmDebug(String portNr = "5005") {
38+
39+
assert !created: "Error, cant enable JVM Debug for a container that has already been crated"
40+
debugPort = portNr
41+
}
3142

3243
/**
3344
* Gets the latest version number from Atlassian Marketplace
@@ -38,9 +49,9 @@ class JsmContainer implements Container {
3849
UnirestInstance unirest = Unirest.spawnInstance()
3950

4051
HttpResponse<JsonResponse> response = unirest.get("https://marketplace.atlassian.com/rest/2/products/key/jira-servicedesk/versions/latest").asJson() as HttpResponse<JsonResponse>
41-
assert response.success : "Error getting latest JSM version from marketplace"
52+
assert response.success: "Error getting latest JSM version from marketplace"
4253
String version = response?.body?.object?.get("name")
43-
assert version : "Error parsing latest JSM version from marketplace response"
54+
assert version: "Error parsing latest JSM version from marketplace response"
4455

4556
unirest.shutDown()
4657

@@ -50,7 +61,7 @@ class JsmContainer implements Container {
5061
@Override
5162
ContainerCreateRequest setupContainerCreateRequest() {
5263

53-
String image = containerImage + ":" + containerImageTag
64+
String image = containerImage + ":" + containerImageTag
5465

5566
log.debug("Setting up container create request for JSM container")
5667
if (dockerClient.engineArch != "x86_64") {
@@ -72,13 +83,24 @@ class JsmContainer implements Container {
7283
ContainerCreateRequest containerCreateRequest = new ContainerCreateRequest().tap { c ->
7384

7485
c.image = image
86+
c.hostname = containerName
87+
c.env = ["JVM_MAXIMUM_MEMORY=" + jvmMaxRam + "m", "JVM_MINIMUM_MEMORY=" + ((jvmMaxRam / 2) as String) + "m", "ATL_TOMCAT_PORT=" + containerMainPort] + customEnvVar
88+
89+
7590
c.exposedPorts = [(containerMainPort + "/tcp"): [:]]
7691
c.hostConfig = new HostConfig().tap { h ->
7792
h.portBindings = [(containerMainPort + "/tcp"): [new PortBinding("0.0.0.0", (containerMainPort))]]
93+
94+
if (debugPort) {
95+
h.portBindings.put((debugPort + "/tcp"), [new PortBinding("0.0.0.0", (debugPort))])
96+
c.exposedPorts.put((debugPort + "/tcp"), [:])
97+
c.env.add("JVM_SUPPORT_RECOMMENDED_ARGS=-Xdebug -Xrunjdwp:transport=dt_socket,address=*:${debugPort},server=y,suspend=n".toString())
98+
}
99+
100+
78101
h.mounts = this.mounts
79102
}
80-
c.hostname = containerName
81-
c.env = ["JVM_MAXIMUM_MEMORY=" + jvmMaxRam + "m", "JVM_MINIMUM_MEMORY=" + ((jvmMaxRam / 2) as String) + "m", "ATL_TOMCAT_PORT=" + containerMainPort] + customEnvVar
103+
82104

83105

84106
}
@@ -88,10 +110,6 @@ class JsmContainer implements Container {
88110
}
89111

90112

91-
92-
93-
94-
95113
boolean runOnFirstStartup() {
96114

97115
ArrayList<String> initialOut = runBashCommandInContainer("echo END")

0 commit comments

Comments
 (0)