The following variables are automatically available in the script.  Refer to the Confluence API documentation for how to use these many of these variables.

All macro parameters are also defined as variables for the script.

Variable, Available, Discussion
out, All, Standard output - stdout. It is a Use to output macro result. Do not use System.out
err, All, Standard error - stderr. It is a Shown if *showErrorOutput=true*
context, All, PageContext for the current page
contentEntityObject, All, ContentEntityObject for the current content
request, All, http servlet request
session, All, http servlet session
contextPath, All, String representing the context path
confluenceHome, All, String representing path to confluence home directory
confluenceDomain, All, String representing base url for this instance.
bandanaManager, All, 
labelManager, All, 
pageManager, All, 
spaceManager, All, 
permissionManager, All, 
contentPermissionManager, All, 
attachmentManager, All, 
commentManager, All, 
userManager, All, 
userAccessor, All, Since 4.3
settingsManager, All, 
searchManager, All, 
contentEntityManager, All, 
webResourceManager, All, Since 4.1
conversionContext, All, Since 4.0
xhtmlContent, All, Since 4.0
html, Groovy\\Gant, Groovy markup builder
binding, Groovy\\Gant, 

Open an issue if you would like to see additional variables provided. This list is occasionally updated make it easier to write simple scripts. The following technique can also be used to get access to additional Confluence components:

UserAccessor userAccessor = (UserAccessor)ContainerManager.getComponent("userAccessor");