Skip to content

Commit f0ffed3

Browse files
author
janatzend
committed
process timeout is now configurable via Variable settings in Bamboo UI
1 parent a8daa62 commit f0ffed3

File tree

8 files changed

+48
-2
lines changed

8 files changed

+48
-2
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,12 @@ The Zend Server Statistics Graph gives you event related data from Zend Server t
100100
[Package Structure]:http://files.zend.com/help/Zend-Server/zend-server.htm#understanding_the_package_structure.htm
101101
[Configuring Tasks]:https://confluence.atlassian.com/display/BAMBOO/Configuring+tasks
102102
[Shared Artifacts]:https://confluence.atlassian.com/display/BAMBOO/Bamboo+Best+Practice+-+Sharing+artifacts
103+
104+
Troubleshooting
105+
---------------
106+
## Process Timeout
107+
If you run into a timeout problem that the process of creating the ZPK or for deploying the app to the server takes more than 60 seconds (default value), you can specify a processTimeout variable in the Build section or in the Deploy section.
108+
For the Build section you can find a 'Variable' tab in the plan configuration.
109+
For the Deploy section you can find a button "Variables" in the environment seettings.
110+
The variable name has to be `processTimeout`, the value has to be an **integer** (unit is **seconds**) according to your needs.
111+
That means that you are able to set the timeout per Plan resp. Deploy but not on a Task level.

pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>org.zend.zendserver.bamboo.plugin</groupId>
66
<artifactId>zendserver</artifactId>
7-
<version>1.2.1</version>
7+
<version>1.2.2</version>
88
<organization>
99
<name>Zend Technologies</name>
1010
<url>http://www.zend.com/</url>
@@ -60,6 +60,7 @@
6060
<configuration>
6161
<productVersion>${bamboo.version}</productVersion>
6262
<productDataVersion>${bamboo.data.version}</productDataVersion>
63+
<enableFastdev>true</enableFastdev>
6364
</configuration>
6465
</plugin>
6566
<plugin>

src/main/java/com/zend/zendserver/bamboo/Env/Build.java

+15
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.atlassian.bamboo.plan.artifact.ArtifactSubscriptionContext;
1212
import com.atlassian.bamboo.task.TaskContext;
1313
import com.atlassian.bamboo.task.TaskDefinition;
14+
import com.atlassian.bamboo.variable.VariableDefinitionContext;
1415

1516
public class Build implements BuildEnv {
1617
public static final String DEFAULT_ZPK_DIR = "/zpk";
@@ -187,4 +188,18 @@ private String getZpkAbsolutePath(File zpk) throws Exception{
187188
logger.addBuildLogEntry("File found: " + zpk.getAbsolutePath());
188189
return zpk.getAbsolutePath();
189190
}
191+
192+
public long getProcessTimeout() {
193+
long processTimeout;
194+
try {
195+
VariableDefinitionContext processTimeoutContext = taskContext.getBuildContext().getVariableContext().getDefinitions().get("processTimeout");
196+
processTimeout = Long.parseLong(processTimeoutContext.getValue()) * 1000;
197+
}
198+
catch (Exception e) {
199+
processTimeout = 60 * 1000;
200+
}
201+
return processTimeout;
202+
203+
204+
}
190205
}

src/main/java/com/zend/zendserver/bamboo/Env/BuildEnv.java

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ public interface BuildEnv {
77
public String getZpkDir() throws Exception;
88
public String getZpkPath() throws Exception;
99
public String getZpkFileName() throws Exception;
10+
public long getProcessTimeout();
1011
}
1112

src/main/java/com/zend/zendserver/bamboo/Env/Deploy.java

+13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.atlassian.bamboo.build.logger.BuildLogger;
99
import com.atlassian.bamboo.task.CommonTaskContext;
1010
import com.atlassian.bamboo.task.TaskDefinition;
11+
import com.atlassian.bamboo.variable.VariableDefinitionContext;
1112

1213
public class Deploy implements BuildEnv {
1314
public static final String ARTIFACT_DOWNLOADER_KEY = "com.atlassian.bamboo.plugins.bamboo-artifact-downloader-plugin:artifactdownloadertask";
@@ -118,4 +119,16 @@ private String getZpkAbsolutePath(File zpk) throws Exception{
118119
zpkPath = zpk.getAbsolutePath();
119120
return zpk.getAbsolutePath();
120121
}
122+
123+
public long getProcessTimeout() {
124+
long processTimeout;
125+
try {
126+
VariableDefinitionContext processTimeoutContext = taskContext.getCommonContext().getVariableContext().getDefinitions().get("processTimeout");
127+
processTimeout = Long.parseLong(processTimeoutContext.getValue()) * 1000;
128+
}
129+
catch (Exception e) {
130+
processTimeout = 60 * 1000;
131+
}
132+
return processTimeout;
133+
}
121134
}

src/main/java/com/zend/zendserver/bamboo/Process/ProcessHandler.java

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public ProcessHandler(Process process, BuildLogger buildLogger)
2424
this.buildLogger = buildLogger;
2525

2626
this.processHandler = new PluggableProcessHandler();
27+
28+
2729
}
2830

2931
public ExternalProcess getExternalProcess() {
@@ -37,6 +39,11 @@ protected ExternalProcessBuilder getProcessBuilder() throws Exception {
3739
.env("HOMEPATH", "\\")
3840
.env("HOMEDRIVE", "c:")
3941
.handler(processHandler);
42+
43+
long processTimeout = buildEnv.getProcessTimeout();
44+
buildLogger.addBuildLogEntry("Set Process Timeout to " + processTimeout / 1000 + " sec");
45+
epb.executionTimeout(processTimeout);
46+
epb.idleTimeout(processTimeout);
4047
return epb;
4148
}
4249

target/zendserver-1.2.2.jar

103 KB
Binary file not shown.

target/zendserver.jar

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
zendserver-1.2.1.jar
1+
zendserver-1.2.2.jar

0 commit comments

Comments
 (0)