Automation Platform Tasks

StepParameters

2 minute read

This class provides methods to process current step parameters, that are either defined in a procedure step or a pipeline task. To initialize a StepParameters object you need to use the getStepParameters() method from Context.

isParameterExists(String parameterName)

Returns true if parameter exists in the current step.

Parameters

(String) Name of parameter

Returns

(Boolean) True if parameter exists.

Usage

if (stepParameters.isParameterExists('endpoint')) {
    ...
}

getParameter(String parameterName)

Returns the Parameter object for the given name.

Parameter

(String) Name of parameter to get.

Returns

Returns Parameter instance for the given parameter name. If parameter with given name doesn’t exist, will return null.

Usage

To retrieve parameter object:

def query = stepParameters.getParameter('query')
println("Query: " +  query.getValue())

Or:

def query = stepParameters.getParameter('query')
println("Query: ${query}")

getCredential(String credentialName)

Returns the Credential object for the given name.

Parameters:

(String) Name of credential’s parameter to get.

Returns

Returns Credential instance for the given parameter name. If parameter with given name doesn’t exist, will return null.

Usage

To retrieve credential object:

def cred = stepParameters.getCredential('credential')
println("UserName: " +  cred.getUserName())
println("Password: " +  cred.getSecretValue())

Or:

def cred = stepParameters.getCredential('credential')
println("Credential: ${cred}") // toString() is overridden, and the password part (secretValue) will be masked

getRequiredParameter(String parameterName)

Returns a Parameter object if parameter exists.

If parameter does not exist, this method will throw an UnexpectedMissingValue exception.

Parameter

(String) Name of parameter

Returns

Returns Parameter instance for the given parameter name.

Usage

To retrieve parameter object:

def query = stepParameters.getRequiredParameter('query')
println("Query: " +  query.getValue())
def query = stepParameters.getRequiredParameter('query')
println("Query: ${query}")

getRequiredCredential(String credentialName)

Returns a Credential object if parameter exists.

If parameter does not exist, this method will throw an UnexpectedMissingValue exception.

Parameter

(String) Name of credential

Returns

Returns Credential instance for the given parameter name.

Usage

To retrieve credential object:

def cred = stepParameters.getRequiredCredential('credential')
println("UserName: " +  cred.getUserName())
println("Password: " +  cred.getSecretValue())

Or:

def cred = stepParameters.getRequiredCredential('credential')
println("Credential: ${cred}") // toString() is overridden, and the password part (secretValue) will be masked

getAsMap()

Returns a Map representation of the parameters. Keys will be parameter names and values will be the parameter values. Value for the credential will be a Credential object reference.

Parameters

None

Returns

Returns Map that is a simplified representation for current values.

Usage

def parametersMap = stepParameters.getAsMap()
println("Query: ${parametersMap['query']}")
println("Username: " + parametersMap['credential'].getUserName())