Hi guys. 

I'm trying to extract some common stuff from a JOB DSL file into some 
scripts which I can then use to augment my jobs to insert some common 
stuff. 

So I'm doing it like the example showed it => 

package utilities

class MyUtilities {
    static void addMyFeature(def job) {
        job.with {
            description('Arbitrary feature')
        }
    }
}

import utilities.MyUtilities

def myJob = job('example')
MyUtilities.addMyFeature(myJob)

Which is fine and it does work. The problem comes in when my Groovy script 
looks like this =>

package utilities

public class JobCommonTemplate {
    public static void addEmailTemplate(def job) {
        job.with {
            publishers {
                String emailScript = readFileInWorkspace(
"packagename/EmailExt_TestResultSummary.groovy")
                wsCleanup()
                extendedEmail('asdf', '$DEFAULT_SUBJECT', '$DEFAULT_CONTENT'
) {
                    configure { node ->
                        node / presendScript << emailScript
                        node / replyTo << '$DEFAULT_REPLYTO'
                        node / contentType << 'default'
                    }
                    trigger(triggerName: 'StillUnstable', subject: 
'$DEFAULT_SUBJECT', body: '$DEFAULT_CONTENT', replyTo: '$DEFAULT_REPLYTO', 
sendToDevelopers: true, sendToRecipientList: true)
                    trigger(triggerName: 'Fixed', subject: 
'$DEFAULT_SUBJECT', body: '$DEFAULT_CONTENT', replyTo: '$DEFAULT_REPLYTO', 
sendToDevelopers: true, sendToRecipientList: true)
                    trigger(triggerName: 'Failure', subject: 
'$DEFAULT_SUBJECT', body: '$DEFAULT_CONTENT', replyTo: '$DEFAULT_REPLYTO', 
sendToDevelopers: true, sendToRecipientList: true)
                }

            }
        }
    }
}

This is all fine, though now that I see it, the static is not needed, I 
think. BUT! readFileInWorkspace or FromWorkspace is not part of the class 
PublisherContext. 

I'm trying to get it to be used from any other implementation of the 
interface which has it, but I don't want to have to implement shitloads of 
other stuff that comes with the JobManagers.

If I override it and use new File('bla').text, I'm in another world of hurt 
since trying to access a local file, is a very bad no - no. 

So, what's the proper way to do this guys? 

THANKS! Any help is very much welcome!! 

Gergely.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/4c217856-70ba-40c4-999d-e0853d642490%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to