Routines for local ruby scripts


This topic provides a list of routines or functions that you can use while creating or updating a script. Routines are required at run time when executing the script. Routines are set directives that you can use to add or modify objects such as applications, components, servers, and properties in the context of the step that is running.

Routines are interpreted only at step completion. Routines are not recognized in the test-mode automation mode. To test them, you must save them in a script, use the script in a step, and run the step or request. The database is updated with relevant information about routines only when the last step in the request is completed, as the automation engine needs a request context.

The automation engine searches the database for each item specified for creation on a case-sensitive basis, and then creates items if there is no match. Since the automation script is run from a step, it has an application, environment and component context. The created items are assigned to the application (or component) and environment (or servers) of the running step.

Routines described in the following table are Ruby-based and therefore can be used for local ruby scripts.

Note

Only the pack_response routine can be applied to local shell and remote shell scripts by using the echo command.

List of routines for adding in a script

Routine

Description

set_property_flag

Updates a property in a step of a request in BMC Release Process Management. If the property name specified in the step is not present in the database, error should be sent.

Note: Only for Ruby-based automation scripts.

Example:

# Creating and Updating an existing environment component property in the step:
properties = "name, value, environment, component, global, private\n"
properties += "Property 01, Script Value 01, Env 01, Comp 01, false, false\n"
properties += "Property 02, Script Value 02, Env 01, Comp 02, true, true\n"
properties += "Private Property 03 New, Script Value 03, Env 01, Comp 01, true, true\n"
set_property_flag(properties)

# Creating a new global property:
createProperty = "name, value, global, private\n"
createProperty += "Private Property 04 New, Script Value 04, true, true\n"
set_property_flag(createProperty)

set_component_flag

Creates or updates application components in BMC Release Process Management.

Note: Only for Ruby-based automation scripts.

Example:

myComponents = "name, version, environment, application\n"
myComponents += "Comp 01 TC864125, Comp Version 01 TC864125, Env 01 TC864125, App 01 TC864125\n"
myComponents += "Comp 03 New TC864125 , Comp Version 03 TC864125, Env 01 TC864125, App 01 TC864125\n"
set_component_flag(myComponents)

set_servers_flag

Creates or updates servers in BMC Release Process Management.

Note: Only for Ruby-based automation scripts.

Example:

servers += "serverName1, Environment1\n"
servers += "serverName2, Environment2\n"
set_servers_flag(servers)

set_application_version

Updates a version of an application in BMC Release Process Management. You can use this routine to update only one version at a time.

Example:

setApp = "App 01"
setAppVersion = "App Version 01"
set_application_version(setApp, setAppVersion)

pack_response

Updates values for output arguments. You can use this routine for updating only one output argument value at a time.

Note: This routine can be used in remote shell and local shell scripts with the echo command.

You can specify this routine in the following format:

  • For Ruby-based scripts: pack_response 'outputArgumentName' 'outputArgumentValue'
  • For remote shell and local shell scripts: echo "pack_response 'outputArgumentName' 'outputArgumentValue'"

Example:

For Ruby-based scripts: pack_response 'jira_tickets' 'JPET-1: Add Link, JPET-2: Add Fish Icon'

For remote shell and local shell scripts: echo "pack_response 'jira_tickets' 'JPET-1: Add Link, JPET-2: Add Fish Icon'"

strip_private_flag(params)

Decrypts all the parameters which are marked as private and update the hash map.

Example:

strip_private_flag(params)
write_to "stripped_params: "
write_to params["Private Property 03 New TC864125"]
write_to params.to_s
write_to "End stripped params:\n"

decrypt_string_with_prefix(val)

Decrypts parameter values which are marked as private. By using this routine, you can return to the original plain text value of the parameter.

Example:

decrypt_string_with_prefix(SS_integration_password_enc)
run_command(..) 

Runs a specified command on the command-line of the target server. The target server refers to your local computer where BMC Release Process Management is installed and running. 

Example:

cmd = "ruby #{params["SS_script_support_path"]\}/amazon_control.rb"
args = "#{"instance_status"} #{params["aws_id"]}"
result = run_command(params, cmd, args)

get_server_list(params)

Lists the various servers selected in the step.

write_to(string)

Prints the given string value (string) in the output file for debugging and troubleshooting purposes.

This information is also available on the Notes tab of the step after the automation is successfully completed.

Example:

write_to "Command_Failed - term not found: [#{params["success"]}]\n"

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*