Use > Automate Release > Release pipeline > Release gate actions > Create a script release gate action

Create a script release gate action

You can create a script release gate action at any stage in a lifecycle, to execute scripts (shell scripts for Linux and Powershell for Windows) in the target machines during the promotion of a package.

Before creating a script release gate action, you must create a resource provider with Provider Type as GitHub. You can later associate this resource provider with a script release gate action. Refer to Provider overview for more information.

Note Ensure that appropriate values are provided in the following fields of the Properties tab when creating the GitHub resource provider:

  • Access Token: A system to authenticate GitHub REST API. Required only if the GitHub repository is private. Leave this field blank if the repository is public. You need to generate the personal access token under 'Settings' in your GitHub account at https://github.n/ or your GHE website, and specify the same here.
  • Owner: Owner of the repository. This is a mandatory field.
  • Proxy: The value required for communication between the Codar machine and GitHub repository server and later between the remote host machine and the GitHub repository server. Mandatory only if the repository needs to be accessed from the local machine.
  • Repository URL : Allows you to limit which content/script is exposed to the user, from the repository. For example, if you want to limit the access to a particular script in a folder, you just need to mention the path of that folder here. The user will not be able to access any script/content other than what is present in this folder.

 

Important Codar does not validate the script content. If there is any malicious data in the script, it might harm the system.

For security reasons, it is recommended that you add an approval action before the script action to validate the contents and mitigate the risk.

To create a script release gate action:

  1. Navigate to Release Automation > Release Pipeline.
  2. Select the design type (topology or sequenced) from the drop-down list in the left pane. (Topology Designs is selected by default).
  3. Select the application and the version for which you want to create a script release gate action.
  4. Click the gear icon next to the stage where you want to create the script action and click Configure Gate Actions.
  5. Click Add Action > Run Script to create a script action.
  6. In the Run Script dialog box, in General tab, fill in the following fields:

    Field Description
    Display Name Name of the script action
    Description Description of the script action
    Select Deployment

    Select the deploy action that you need to associate with the script action. All the deploy actions that have been created for the selected package are displayed.

    If you do not select a deploy action here, then you will be able to map a constant value or a context property in the Parameters tab. Whereas if you select a deploy action, you will have an additional option to map a component property.

    In the Success and Failure Configuration area, select the check boxes as applicable:

    Check box Description
    Notify on Success Select this check box for a notification message to be sent if the script action executes successfully. The notification message is sent to the user who initiated the promotion request.
    Notify on Failure Select this check box to receive a notification email if the script action fails to execute successfully. The notification message is sent to the user who initiated the promotion request.
    Reject on Failure (Blocking) Select this check box to reject the package if the script action fails to execute successfully.
    Ignore on Failure Select the check box to mark the specified action optional (non-blocking). The execution will move to the next release gate action even if the action fails to execute successfully.
    You can select more than one check box. However, for the Reject on Failure and the Ignore on Failure options, you can select only one of them at the same time.
  7. Click Next.

  8. In Host Details tab, fill in the following details:
    1. Time Out (in Seconds): Specify the maximum duration after which the script execution must time out.
    2. OS Type: Select the type of operating system on which the script is to be executed, from the drop-down list.

      Script actions under Linux OS type can run scripts and hence can be executed on Ubuntu, RHEL, etc.

      Script actions under Windows OS type can run powershell scripts on Windows platform such as Windows 2012.

      Note It is a prerequisite that script executions be allowed beforehand on the host machine being configured. For example, in case of a Windows host machine, the ExecutionPolicy should be set.

    3. Host Details
    FieldDescription
    Host NameName of the host machine on which the script is to be executed.
    Host PasswordHost machine password.
    Host Private KeyHost machine private key (applicable to Linux machines only).
    Host User NameHost machine user name.

    You can add or edit values in each of the above fields (parameters). To do so:
    1. Select the gear icon next to the parameter you want edit and click Edit.
    2. In the Edit Parameter Mapping dialog box, fill in the following fields:

      FieldDescription
      Display NameName of the parameter. You cannot change the default name.
      DescriptionDescription of the parameter.
      Mapping Type

      Object that you want to map the parameter to. You can either map the parameter to a component property, context property or constant value.

      If you select Context Property as the Mapping Type, you must select any of the following Context properties from the Value field.

      If you select Constant Value as the Mapping Type, you ,must provide a constant value in the Value field.

      If you have selected a deploy action in the General tab, then you can also select mapping type Component Property. If you select Component Property or Package Property, then you must also select the components and the component property.

      Note: For Mapping Type as 'Package Property', the system picks up the updated value of a package property for the selected Component.

      If a deploy action is not associated with this script action, then you can map a either a constant value or a context property only. Whereas if a deploy action is associated with it, then you will have an additional option to map a component property.

      Select 'Release Gate Action' to map the output parameters of one release gate action as input parameters to the next release gate action.

      Note: The release gate action being mapped to another release gate action must be such that it generates output parameters upon successful execution.

      Value

      Select one of the following values:

      • Source Lifecycle Stage
      • Destination Lifecyle Stage
      • Package Name
      • Action Instance Id
      • Request User
      Gate Actions

      Displayed only if you selected Release Gate Actions in the Mapping Type field.

      Select the gate action you want to map to this gate action.

      Gate Action Properties

      Displayed only if you selected Release Gate Actions in the Mapping Type field.

      Select the gate action property to be mapped to this gate action.

      Mapping of parameters marked with an asterisk is mandatory. If you do not map such parameters, an error message is displayed when you try to add a script action.

    You can also unmap a parameter that is already mapped to a component. To unmap a parameter from a component, select the gear icon next to the parameter and click Unmap.

  9. Click Next.
  10. In the Script Details tab, fill in the following fields:

    FieldDescription
    SCM Type

    Select the GitHub provider through which you want to execute the script.

    SCM Instance

    Select the script instance. If there is an error in Provider configuration, an appropriate error message will be displayed and you cannot proceed further until the error is fixed.

  11. Click Next.
  12. In the Script Arguments tab, add the script arguments. To do so:
    1. Click the gear icon next to 'Argument0' and select 'Edit'.

    2. In the Edit Parameter Mapping dialog, specify the details as explained above for Host Details tab.

    3. Click Save.
    4. Click '+' icon and repeat procedure from 'a' to 'c' to add as many arguments as you need.

  13. Click Add Action.

The script action that you added will be listed in the Configure Gate Actions dialog box.

Note Running script action (such as Windows PowerShell) on the target machine is not supported when both Codar and OO are installed on a non-Windows machine. To overcome this limitation, you must set up an OO RAS (Remote Action Services) server on a Windows machine, which will in turn run the script action on the target machine. Refer to 'Operations Orchestration Installation, Upgrade, and Configuration' guide for information on installing and configuring an OO RAS server.

How Codar handles concurrency issues: When multiple script actions are being executed on the same host, the downloaded script filename is appended with a random number. Hence, name of the file will be <git_file_name><random_number>.

In addition, the file will be removed from the system after a successful execution of the script. In case the script execution fails, the respective file will be retained for debugging purpose.