Title: [41236] trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/VncRecorderBuildWrapper.java: improved error handling
Revision
41236
Author
tbaum
Date
2015-02-20 12:04:06 -0500 (Fri, 20 Feb 2015)

Log Message

improved error handling

Modified Paths


Diff

Modified: trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/VncRecorderBuildWrapper.java (41235 => 41236)


--- trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/VncRecorderBuildWrapper.java	2015-02-16 20:50:38 UTC (rev 41235)
+++ trunk/hudson/plugins/vncrecorder/src/main/java/org/jenkinsci/plugins/vncrecorder/VncRecorderBuildWrapper.java	2015-02-20 17:04:06 UTC (rev 41236)
@@ -160,8 +160,11 @@
 		String vncServReplaced = Util.replaceMacro(vncServ,build.getEnvironment(listener));
 		String vncPasswFilePathReplaced = Util.replaceMacro(vncPasswFilePath,build.getEnvironment(listener));
 		//String outFileBase = build.getEnvironment(listener).get("JOB_NAME") + "_" +  build.getEnvironment(listener).get("BUILD_NUMBER") + ".swf";
+		if (outFileName == null || outFileName.equalsIgnoreCase("null"))
+		{
+			outFileName = "${JOB_NAME}_${BUILD_NUMBER}";
+		}
 		String outFileBase =  Util.replaceMacro(outFileName,build.getEnvironment(listener)) + ".swf";
-		
 		vncLogger.info("Recording from vnc server: " + vncServReplaced);
 		vncLogger.info("Using vnc passwd file: " + vncPasswFilePathReplaced);
 		vncLogger.setLevel(Level.WARN);
@@ -187,6 +190,11 @@
 			artifactsDir.mkdir();
 		}
 
+		if (outFileBase == null || outFileBase.equalsIgnoreCase("null.swf"))
+		{
+			outFileBase = build.getNumber() + ".swf";
+
+		}
 		final File outFileSwf = new File(artifactsDir,outFileBase); 
 		final File outFileHtml = new File(outFileSwf.getAbsolutePath().replace(".swf", ".html"));
 
@@ -205,9 +213,15 @@
 			public boolean tearDown(AbstractBuild build, BuildListener listener)
 					throws IOException, InterruptedException {
 				final Date to = new Date();
-				recordState.cancel(true);
-				Thread.sleep(1000);
+				if (recordState != null)
+				{	
+					recordState.cancel(true);
+					Thread.sleep(1000);
+				}
+				if (removeIfSuccessful == null)
+					removeIfSuccessful = false;
 
+
 				if ((removeIfSuccessful && outFileSwf.exists()) && (build == null || build.getResult() == Result.SUCCESS || build.getResult() == null)  )
 				{
 					vncLogger.info("Build successful: Removing video file " + outFileSwf.getAbsolutePath() + " \n");
@@ -296,8 +310,8 @@
 			save();
 			return true;
 		}
-		
-		
+
+
 		public FormValidation doCheckVncServ(@AncestorInPath AbstractProject<?,?> project, @QueryParameter String value ) {
 			// Require CONFIGURE permission on this project
 			if(!project.hasPermission(Item.CONFIGURE)){
@@ -321,8 +335,8 @@
 			//				String vnsServCom = "Example for start of vncserver: " + value.split(":").length == 2 : ;
 			return FormValidation.okWithMarkup("<strong><font color=\"blue\">Please, make sure that your vncserer is running on '" + value  + "'</font></strong>");
 		}
-		
 
+
 		public FormValidation doCheckOutFileName(@AncestorInPath AbstractProject<?,?> project, @QueryParameter String value ) {
 			// Require CONFIGURE permission on this project
 			if(!project.hasPermission(Item.CONFIGURE)){
@@ -350,8 +364,8 @@
 		{
 			return "localhost:88";
 		}
-		
 
+
 		public String getDefaultOutFileName() {
 			return "${JOB_NAME}_${BUILD_NUMBER}";
 		}

--
You received this message because you are subscribed to the Google Groups "Jenkins Commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-commits+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to