Skip to main content
Version: Early Access

Rule objects and properties

When you define an XML or script rule in Deploy, you use expressions or scripts to define its behavior. These are written in Jython, a combination of Python and Java.

Objects that can have rules applied

The data available for a planning script depends on the scope of the rule. This table shows when each object is available:

Object nameTypeScopeDescription
contextDeploymentPlanningContextallUse this to add steps and checkpoints to the plan.
deployedApplicationDeployedApplicationallSpecifies which application version will be deployed to which environment. Not available in the case of DESTROY.
previousDeployedApplicationDeployedApplicationallThis is the previous application version that was deployed.
stepsallEnables you to create steps from the step registry. For more information, see Use a predefined step in a rule.
specificationDeltaSpecificationpre-plan
post-plan
Contains the delta specification for the current deployment.
deltaDeltadeployedWhether the deployed should be created, modified, destroyed, or left unchanged (NOOP).
deployedDeployeddeployedIn the case of CREATE, MODIFY, or NOOP, this is the "current" deployed that the delta variable refers to. In the case of DESTROY, it is not provided.
previousDeployedDeployeddeployedIn the case of MODIFY, DESTROY, or NOOP, this is the "previous" deployed that the delta variable refers to. In the case of CREATE, this is not provided.
deltasDeltasplanCollection of every Delta in the current InterleavedPlan.
controlServiceControlServiceallGives you access to the ControlService.
deploymentServiceDeploymentServiceallGives you access to the DeploymentService.
inspectionServiceInspectionServiceallGives you access to the InspectionService.
metadataServiceMetadataServiceallGives you access to the MetadataService.
packageServicePackageServiceallGives you access to the PackageService.
permissionServicePermissionServiceallGives you access to the PermissionService.
repositoryServiceRepositoryServiceallGives you access to the RepositoryService.
roleServiceRoleServiceallGives you access to the RoleService.
serverServiceServerServiceallGives you access to the ServerService.
taskServiceTaskServiceallGives you access to the TaskService.
taskBlockServiceTaskBlockServiceallGives you access to the TaskBlockService.
userServiceUserServiceallGives you access to the UserService.
loggerLoggerallProvides access to the Deploy logs. Prints logs to namespace com.xebialabs.platform.script.Logging.
note

These objects are not automatically available for execution scripts, such as in the jython or os-script step. If you need an object in such a step, the planning script must make the object available explicitly. For example, by adding it to the jython-context map parameter in the case of a jython step.

Accessing CI properties

To access configuration item (CI) properties, including synthetic properties, use the property notation. For example:

name = deployed.container.myProperty

You can also refer to a property in the dictionary style, which is useful for dynamic access to properties. For example:

propertyName = "myProperty"
name = deployed.container[propertyName]

For full, dynamic read-write access to properties, you can access properties through the values object. For example:

deployed.container.values["myProperty"] = "test"

Accessing deployeds

In the case of rules with the plan scope, the deltas object will return a list of delta objects. You can get the deployed object from each delta. For more information, see Plan scope and Deltas.

The delta and delta specification expose the previous and current deployed. To access the deployed that is going to be updated, use the deployedOrPrevious property:

depl = delta.deployedOrPrevious
app = specification.deployedOrPreviousApplication

Comparing delta operations and types

You can compare a delta operation to the constants "CREATE", "DESTROY", "MODIFY" or "NOOP" as follows:

if delta.operation == "CREATE":
pass

You can compare the CI type property to the string representation of the fully qualified type:

if deployed.type == "udm.Environment":
pass