Where are the instance variables coming from on the email-ext jelly/groovy scripts?
Asked Answered
C

1

11

The templates and examples provided by the email-ext plugin on jenkins reference variables such as build, root, it, etc.... Where are these variables coming from and where is the documentation on them? I understand to some extent that it is the reference to the plugin instance, but that's about where my understanding ends.

If you need reference to the scripts you can see some examples here: https://github.com/jenkinsci/email-ext-plugin/tree/master/src/main/resources/hudson/plugins/emailext/templates

Cerenkov answered 2/4, 2012 at 16:36 Comment(0)
C
14

build: hudson.model.AbstractBuild - your build instance.

project == build.getParent() - the job instance for your build.

it: ScriptContentBuildWrapper(build) (internal ExtEmail class)

rootUrl Jenkins URL as set in your Jenkins configuration

template: template name

Here is EmailExt plugin code link. What you are looking for is in the method ScriptContent.createEngine().

For reference, here is Jenkins API link.

Carmencarmena answered 2/4, 2012 at 20:32 Comment(2)
When using a build step "Execute system Groovy script" the variable rootURL does not exist. I'm using this helper function: def getRootUrl(useAbsoluteUrl=false) { ` def instance = Jenkins.getInstance()` ` return useAbsoluteUrl ? instance.getRootUrl()` ` : (instance.servletContext.getContextPath()+"/")` }Lahey
And the class where the is 'build', 'it', 'project' etc names are actually set to refer to their real objects is here - the JellyScriptContent class: github.com/jenkinsci/email-ext-plugin/blob/…Arbitration

© 2022 - 2024 — McMap. All rights reserved.