<< Back to previous view

[QB-1298] Running Groovy script to create file but not able to see file
Created: 26/Jun/12  Updated: 27/Jun/12

Status: Resolved
Project: QuickBuild
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major
Reporter: esya Assigned To: Robin Shen
Resolution: Won't Fix Votes: 0
Remaining Estimate: Unknown Time Spent: Unknown
Original Estimate: Unknown


 Comments   
Comment by Robin Shen [ 26/Jun/12 11:38 PM ]
Can you please show me your script?
Comment by esya [ 26/Jun/12 11:54 PM ]
First sorry for this simple question. I am new at QuickBuild

It is a very simple script.

groovy:
import java.io.File;
new File("build_log.txt");

The configuration runs successfully but I do not see the file.
Comment by esya [ 27/Jun/12 12:10 AM ]
Could you please let me know why I am able to get the file when the script is like this:

groovy:
new File(configuration.workspaceDir, "build_status.txt").text = build.status.name();

But I am not able to get when script is like this:

groovy:
new File(configuration.workspaceDir, "build_status.txt")

Can I create an empty file?
Comment by Robin Shen [ 27/Jun/12 12:26 AM ]
To create an empty file, please try this:
new File(configuration.workspaceDir, "build_status.txt").text = ""
Comment by esya [ 27/Jun/12 12:41 AM ]
Thank you this worked for me.

But still I am not able to get the files for the following script

groovy:
address = "ftp://xx.com/file.zip"

file = new FileOutputStream("download.zip")

new BufferedOutputStream(file) << new URL(address).openStream()
Comment by Robin Shen [ 27/Jun/12 12:46 AM ]
Are you able to run this script outside of QB successfully (using groovy shell or something else)? If not, it is rather a groovy problem then.
Comment by esya [ 27/Jun/12 12:47 AM ]
Yes I am able to run this script out side and I checked the downloaded files they are exactly same.
Comment by Robin Shen [ 27/Jun/12 01:31 AM ]
I just tried and below works for me:

groovy:
address = "http://xx.com/file.zip" // I am trying http since I do not find a ftp source to download)

file = new FileOutputStream(new File(configuration.workspaceDir, "download.zip")) // make sure to create file under workspace directory explicitly; otherwise, files will be created under working directory of the process, which is "<QB install dir>/bin"

new BufferedOutputStream(file) << new URL(address).openStream()
Comment by esya [ 27/Jun/12 01:37 AM ]
Thank you very much.

I checked. All the files I downloaded are under bin because I did not create workspace directory.
Generated at Fri Sep 26 22:22:07 UTC 2025 using JIRA 189.