How Validate File Downloaded When Running Through A Pipeline?

I use the below custom keyword when validating whether a file is downloaded and it works totally fine when running locally

public class DownloadManager {

def isFileDownloaded(String filePath,String fileName) {

	File dir = new File(filePath);
	File[] dirContents = dir.listFiles();
	String lastAttempt = '';
	if (dirContents.length > 0) {
		for (int i = 0; i < dirContents.length; i++) {
			if (dirContents[i].getName().equals(fileName)) {
				// File has been found, it can now be deleted:
				KeywordUtil.markPassed(fileName + ' exist in ' + filePath + ' and was deleted')
				return true;
			lastAttempt = dirContents[i].getName().equals(fileName);
		if (lastAttempt != fileName) {
			KeywordUtil.markFailed(fileName + ' does not exist in ' + filePath)
			return false;
	return false;

But when I execute this on the pipeline (bitbucket) it is failing mainly because Im not sure how to verify when it is running and downloading through a docker. Is there a way we could set the download location within the project itself to validate whether the file is downloaded? Or is there other workaround?

Thanks in advance!

1 Like

Also is it possible for a workaround like set download path to katalon project itself and delete when the validation is done? Thanks

1 Like

It seems you want to know how to get the path of Katalon project directory. The following code does that.

import com.kms.katalon.core.configuration.RunConfiguration

String projectDir = RunConfiguration.getProjectDir()

println projectDir

This code works the same on a local box and on a remote server.