Thanks that is exactly what I needed. I ended up using the following:

<% def versionString = ""
def channel = null
if (build.workspace.isRemote())
{
channel = build.workspace.channel
}

fp = new hudson.FilePath(channel, build.workspace.toString() + 
"\\Build\\version.txt")
if (fp != null) {
versionString = fp.readToString()
} %>

Which appears to work well. I'm sure there is a much cleaner way of doing 
it (so if you have suggestions by all means send me an email).

As far as working around the outdated mod problem of modifying the subject 
I ended up having my build script dump my email subject and using 
${BUILD_LOG_REGEX, regex="my_subject_regex", linesBefore=0, linesAfter=0, 
maxMatches=1, showTruncatedLines=false} in the email-ext subject line to 
pick it up thus accomplishing the same thing I was doing with a pre-send 
script.


On Monday, October 15, 2012 5:49:05 PM UTC-7, slide wrote:
>
> You probably want to look at the FilePath [1] documentation and use that 
> in the script. As for modifying the subject, you will need to upgrade to 
> >2.22 for that.
>
> Thanks,
>
> slide
>
> [1] - http://javadoc.jenkins-ci.org/hudson/FilePath.html
>
>
> On Mon, Oct 15, 2012 at 5:27 PM, Bryan Hunt <brya...@gmail.com<javascript:>
> > wrote:
>
>> New subscriber here...
>>
>> I have searched through the archives looking for an answer but haven't 
>> yet been able to find a solution to my problem (even though it appears this 
>> question has been asked before)
>>
>> I have specific build output that I need to load into my email-ext script 
>> (a specially formatted version string) so I have the following code in the 
>> start of my groovy script which works fine if everything is executed from 
>> the master but fails otherwise
>>
>> <% def versionString = ""
>> fr = new FileReader(build.workspace.toString() + "\\Build\\version.txt")
>> if (fr != null) {
>> versionString = fr.readLine()
>> } %>
>>
>> Produces the following error:
>>         Exception: javax.script.ScriptException: 
>> java.io.FileNotFoundException: 
>> c:\jenkins\workspace\project_name\Build\version.txt (No such file or 
>> directory)
>>
>> ****
>>
>> So aside from the obvious need for a try/catch block does anyone have 
>> a recommendation for loading a file from a slave?
>> Regards,
>> Bryan H.
>>
>> P.S. Is there a way to change the MimeMessage.subject from inside the 
>> groovy body script (or do I have to ask my administrator to kindly update 
>> the plugin to a version > 2.22)?
>>
>
>
>
> -- 
> Website: http://earl-of-code.com
>  

Reply via email to