Enforce that a Global Process can only be called by another process

1 Likes

ISSUE:

Micro Focus Deployment Automation allows you to create Global Processes that exist outside of Applications and Components. These processes can be used to create reusable processes that can be used across multiple applications - for example applying snapshot and version statuses. In such a scenario you do not want the Global Processes to be called directly as this will circumvent your process, instead you would want to enforce that they can only be callable from a "parent" process.

HOW TO STEPS:

If a Global Process is executed from a parent process then the property "parent.property.context.id" will be set. We can use this fact to determine whether to continue or stop the process. One way to do this in the Global Process is to add a Switch step as the first step which checks whether this property is set. In order to continue with the process we can use a regular expression to check if the property has a value. The value if it does will be a UUID, something like "b48672b7-a4d8-460b-b666-8b4a3c95c86d" so we can use the regular expression: "/[a-z0-9] $/". The other branch can have the "Default" option selected and should fail the process. One way to achieve this is to add a "Run Groovy Script" step with content:

println "This process may not be run directly. It must be called by another process." System.exit(1)

An example of the process is illustrated below:

only-run-from-parent.png
You can achieve the same result without a Switch step by putting a precondition on the "Stop Process" step as follows:

!properties.get(parent.property.context.id)

However this will result in a "Precondition failed" in the Log which I think could confuse some users.

Labels:

How To-Best Practice
Support Tip
Comment List
Anonymous
Related Discussions
Recommended