A groovy script can be used in custom gates and steps, as well as for many configuration values on specific steps or gates. Additionally, a gate or step can be skipped by providing a Precondition groovy script. This page includes some sample scripts for these scenarios. See Pipeline Groovy Variables and Methods for a full listing of the accessible variables and methods in these groovy scripts.
Custom Gates and Steps
...
Code Block |
---|
|
def projects = stgexec.getSnapshotProjects();
for (def project in projects)
{
if (project.getProjectType() != null)
{
if ('EBS'.equals(project.getProjectType()))
{
stgexecinfo.setInstanceOverride(project.getProjectId(), project.getPackageName(), 'EBS');
}
}
} |
Validate Snapshot Contents
A pipeline can prevent deployments of any unexpected projects in the snapshot with a script similar to the following. This would best be implemented as a custom gate in the first stage of the pipeline.
Code Block |
---|
|
expectedProjects = "HRWLSConfigurations,HRMDSObjects,HRSOAService,HRJavaApp,ValidatePaymentSB".split(",");
for (p in stgexec.getSnapshotProjects())
{
if (!expectedProjects.contains(p.getProjectName()))
{
return "FAILED";
}
}
return "SUCCESSFUL"; |
Precondition Scripts
Execute Step Only for Specific Object Type
This could be used to conditionally call a Restart OACore or Generate Jar utility workflow only if OAF_JAVA files are deployed.
Code Block |
---|
|
def deployedTypes = stgexec.getProjectWorkflowOutputValues("DeployedTypes");
for (String listItem : deployedTypes)
{
If (listItem.contains('OAF_JAVA'))
{
return true;
}
}
return false; |