Log Message
use build.getWorkspace().child() for path resolution
Modified Paths
Diff
Modified: trunk/hudson/plugins/imagecomparison/src/main/java/org/jenkinsci/plugins/imagecomparison/ImageComparator.java (41358 => 41359)
--- trunk/hudson/plugins/imagecomparison/src/main/java/org/jenkinsci/plugins/imagecomparison/ImageComparator.java 2015-06-03 12:39:52 UTC (rev 41358)
+++ trunk/hudson/plugins/imagecomparison/src/main/java/org/jenkinsci/plugins/imagecomparison/ImageComparator.java 2015-06-05 15:32:48 UTC (rev 41359)
@@ -25,6 +25,7 @@
package org.jenkinsci.plugins.imagecomparison;
import hudson.Extension;
+import hudson.FilePath;
import hudson.Launcher;
import hudson.Util;
import hudson.model.BuildListener;
@@ -36,7 +37,6 @@
import hudson.tasks.Recorder;
import java.awt.image.BufferedImage;
-import java.io.File;
import java.io.IOException;
import java.io.Serializable;
@@ -89,19 +89,21 @@
}
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
- String image1Replaced = Util.replaceMacro(image1 ,build.getEnvironment(listener));
- String image2Replaced = Util.replaceMacro(image2, build.getEnvironment(listener));
- File f1 = new File(image1Replaced);
- File f2 = new File(image2Replaced);
- if(!f1.isFile() || !f1.canRead())
+ String image1Replaced = Util.replaceMacro(image1 ,build.getEnvironment(launcher.getListener()));
+ String image2Replaced = Util.replaceMacro(image2, build.getEnvironment(launcher.getListener()));
+
+ FilePath f1 = build.getWorkspace().child(image1Replaced);
+ FilePath f2 = build.getWorkspace().child(image2Replaced);
+
+ if(!f1.exists())
{
- listener.error("Can't access " + f1.getAbsolutePath() + "!\n");
+ listener.error("Can't access " + f1.getRemote() + " !\n");
return false;
}
- if(!f2.isFile() || !f2.canRead())
+ if(!f2.exists())
{
- listener.error("Can't access " + f2.getAbsolutePath() + "!\n");
+ listener.error("Can't access " + f2.getRemote() + " !\n");
return false;
}
@@ -128,16 +130,16 @@
}
}
- public static float compareImages(File f1, File f2) throws IOException
+ public static float compareImages(FilePath f1, FilePath f2) throws IOException, InterruptedException
{
float ret = -1;
int q = 0;
- BufferedImage image = ImageIO.read(f1);
+ BufferedImage image = ImageIO.read(f1.read());
int widthOfImage1 = image.getWidth();
int heightOfImage1 = image.getHeight();
int[][] bufOfImage1 = new int[widthOfImage1][heightOfImage1];
- BufferedImage images = ImageIO.read(f2);
+ BufferedImage images = ImageIO.read(f2.read());
int widthOfImage2 = images.getWidth();
int heightOfImage2 = images.getHeight();
int[][] bufOfImage2 = new int[widthOfImage2][heightOfImage2];
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.