[Anthill-pro] RE: No such file exception
Steve Boone
sbb at urbancode.com
Fri May 16 09:10:54 CDT 2008
There is an example script that does essentially the same thing here.
http://bugs.urbancode.com/browse/AHPSCRIPTS-36
The example script, parses the output from a build step (In your case it
will parse the outoput of a build step too, it just a Shell builder) and
depending on the output, performs certain logic.
You can follow the same idea for your script.
a) echo the output of the script in a shell builder.
b) create an evalaute script step
c) The step should find the shell builder step, and collect the log
information .
// BUILD_STEP_NAME: Name of the step within the job that should be inspected
String BUILD_STEP_NAME = "build";
BuildLifeJobTrace jobTrace = JobTraceLookup.getCurrent();
StepTrace[] stepTraceArray = jobTrace.getStepTraceArray();
StepTrace stepTrace = null;
for (int j = 0; j < stepTraceArray.length && stepTrace == null; j++) {
if (stepTraceArray[j].getName().equalsIgnoreCase(BUILD_STEP_NAME)) {
stepTrace = stepTraceArray[j];
break;
}
}
String outputLog = LogHelper.getOutput(stepTrace.getCommandTraceArray()[0]);
d) then, parse through the informationin the log, and get your stamp, once
you have your stamp, save it as a property.
On Fri, May 16, 2008 at 9:56 AM, Maxim Bruy <maxim.bruy at ctco.lv> wrote:
> Can be there is an opportunity to show an example of such script or would
> like to specify on api for realization of it.
>
>
>
> >The Evaluate script step, runs on the server side, so they way you have it
>
> >set up the file will never be found.
>
> >
>
> >Your best options is to have a
>
> >
>
> >a) Shell Builder that echo's the contents of the file you want to parse.
>
> >
>
> >b)Evalaute script step that reads in the output of that shell builder step,
>
> >and parses the information to get your stamp .
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >On Fri, May 16, 2008 at 8:51 AM, Steve Boone <sbb at urbancode.com <http://lists.urbancode.com/mailman/listinfo/anthill-pro>> wrote:
>
> >
>
> >* The file would have to be on the agent.*
>
> >
>
> >
>
> >* I understand you ar trying to read in a particular file, where is the file*
>
> >* located? Is it on the agent, or on the server? Is the server and agent on*
>
> >* the same machine?*
>
> >
>
> >
>
> >
>
> >* On **Fri, May 16, 2008** at **5:45 AM**, Maxim Bruy <maxim.bruy at ctco.lv <http://lists.urbancode.com/mailman/listinfo/anthill-pro>> wrote:*
>
> >
>
> >>* Can be there is an opportunity to be connected to file system of the agent because it's look like that the script works on a server side*
>
> >>
>
> >>
>
> >>
>
> >>* >The error is saying that it can not find the file called "file.to.read"*
>
> >>
>
> >>* >change your script so that*
>
> >>
>
> >>* >*
>
> >>
>
> >>* >String path = "/file.to.read";*
>
> >>
>
> >>* >*
>
> >>
>
> >>* >actually is the name of the file you are trying to read.*
>
> >>
>
> >>* >*
>
> >>
>
> >>* >*
>
> >>
>
> >>* >*
>
> >>
>
> >>* >*
>
> >>
>
> >>* >On Thu, **May 15, 2008** at **9:40 AM**, Maxim Bruy <maxim.bruy at ctco.lv <http://lists.urbancode.com/mailman/listinfo/anthill-pro>> wrote:*
>
> >>
>
> >>* >*
>
> >>
>
> >>* >>* Running this script**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>* import java.io.InputStreamReader;**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>* import java.io.FileInputStream;**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>* String path = "/file.to.read";**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>* BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(path)));**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>* String s;**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>* while ((s = in.readLine()) != null) {**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>* print "done";**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>* }**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>* in.close();**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>* I'm getting exception like:**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>* 2008-05-15 **16:31**:54,946 ERROR 674931 0 0 - Exception:**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>* 2008-05-15 **16:31**:54,946 ERROR 674931 0 0 - org.apache.bsf.BSFException: The application script threw an exception: java.io.FileNotFoundException: /file.to.read (No such file or directory) BSF info: noFile at line: 0 column: columnNo**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>* 2008-05-15 **16:31**:54,946 ERROR 674931 0 0 - com.urbancode.anthill3.runtime.scripting.ScriptException: org.apache.bsf.BSFException: The application script threw an exception: java.io.FileNotFoundException: /file.to.read (No such file or directory) BSF info: noFile at line: 0 column: columnNo**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>* _______________________________________________**
>
> >>
>
> >>* >>* Anthill-pro mailing list**
>
> >>
>
> >>* >>* Anthill-pro at lists.urbancode.com <http://lists.urbancode.com/mailman/listinfo/anthill-pro>**
>
> >>
>
> >>* >>* http://lists.urbancode.com/mailman/listinfo/anthill-pro**
>
> >>
>
> >>* >>*
>
> >>
>
> >>* >>*
>
> >>
>
> >>
>
> >>
>
> >>* _______________________________________________*
>
> >>* Anthill-pro mailing list*
>
> >>* Anthill-pro at lists.urbancode.com <http://lists.urbancode.com/mailman/listinfo/anthill-pro>*
>
> >>* http://lists.urbancode.com/mailman/listinfo/anthill-pro*
>
> >>
>
> >>
>
> >
>
>
>
> _______________________________________________
> Anthill-pro mailing list
> Anthill-pro at lists.urbancode.com
> http://lists.urbancode.com/mailman/listinfo/anthill-pro
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.urbancode.com/pipermail/anthill-pro/attachments/20080516/b124be9b/attachment-0001.htm
More information about the Anthill-pro
mailing list