You can use a custom script task to configure bash or powershell scripts and run scripts on any Linux or Windows machine. After the script runs, you can monitor the script progress and capture the script response, which you can pass as input to other release pipeline tasks.

Prerequisites

  • Verify that you defined and configured the plug-ins. An instance of this plug-in must be created in vRealize Orchestrator to enable the plug-ins in the pipeline. See the Installation and Configuration guide.

  • Verify the following for Bash script orchestration:

    • SSH service is configured on the Linux host.

    • Verify SSHD configuration MaxSessions is 50.

  • Verify the following for Powershell script orchestration:

    • Winrm service is configured on the Windows host.

    • Verify winrm is configured for MaxShellsPerUser and MaxMemoryPerShellMB.

Procedure

  1. Click the Code Stream tab.
  2. Select an existing pipeline to configure from the Pipeline tab.
  3. Select Edit > Stages.
  4. Select Add Task.
  5. Select Script from the Provider drop-down menu.
  6. Enter a name for this custom task and click OK.
  7. Select the new task from the stage column.
  8. Confirm to save the pipeline.
  9. Select an Execute Task for the release pipeline.

    Option

    Description

    Always

    Runs the release pipeline task without conditions.

    On Condition(s)

    Runs the release pipeline task only if the defined condition is evaluated as true. If the condition is false, the task is skipped.

    A boolean expression using the following operands and operators is supported.

    • Pipeline variables such as, ${pipeline.variableName}. Curly brackets are reserved for specifying pipeline variables.

    • Task output variables such as, ${Stage1.task1.machines[0].value.hostIp[0]}

    • Default pipeline binding variables such as, ${releasePipelineName}

    • Case insensitive Boolean values such as, true, false, 'true', 'false'

    • Integer or decimal values without quotes

    • String values used with single or double quotes such as, "test", 'test'

    • String and Numeric types of values such as, == Equals and != Not Equals

    • Relational operators such as, > , >=, <, and <=

    • Boolean logic such as, && and ||

    • Arithmetic operators such as, +, -, *, and /

    • Nested expressions using round brackets

    • Strings with literal value ABCD is evaluated as false and the task is skipped.

    Unary operators are not supported.

    A sample condition, ${Stage1.task1.output} == “Passed” || ${pipeline.variableName} == 39

  10. (Optional) : Select the Continue Pipeline execution even if this task fails option .

    This option allows the release pipeline to bypass the failed task and continue with the execution process.

Results

After a custom script task runs, the EXECUTION_ID_FOLDER run folder containing logFile and exitStatusFile is created in the following paths mentioned below:

Bash Script

Location

Remote script

<CODESTREAM_FOLDER_PATH>/<ScriptName>

Example: /var/tmp/codestream/demo/f8e27157-792f-428e-8bbd-f88ac106ddd2

Inline script

<CODESTREAM_FOLDER_PATH>/user_defined_script

Example: /var/tmp/codestream/user_defined_script/e05606b8-8acb-43c7-9293-a465e86cc3fe

Powershell Script

Location

Remote script

<CODESTREAM_FOLDER_PATH>/<ScriptName>

Example: C:\Users\fritz\AppData\Local\Temp\codestream\demo\f8e27157-792f-428e-8bbd-f88ac106ddd2

Inline script

<CODESTREAM_FOLDER_PATH>/user_defined_script

Example: C:\Users\fritz\AppData\Local\Temp\codestream\user_defined_script\e05606b8-8acb-43c7-9293-a465e86cc3fe

Following are the Script plugin system properties, which can be configured on the vRealize Code Stream appliance:

Table 1. Bash Script

Property Name

Descriptiton

Default Value

fms.bundle.script.bash.codestream.folder

Configure path for codestream folder where script execution folder will be created.

/var/tmp/codestream/

fms.bundle.script.bash.log.snippet.lines

Configure number of lines for the log snippet displayed in script response.

50

fms.bundle.script.bash.log.snippet.line.length

Configure the maximum characters per log line after which the log will be truncated.

1024

fms.bundle.script.bash.upload.chunk.bytes

For inline script, the data is uploaded in chunks and this property is used to configure chunk size.

1024 * 50

Table 2. Powershell Script

Property Name

Descriptiton

Default Value

fms.bundle.script.powershell.codestream.folder

Configure path for codestream folder where script execution folder will be created.

C:\Users\<User_Name>\AppData\Local\Temp\codestream\

fms.bundle.script.powershell.log.snippet.lines

Configure number of lines for the log snippet displayed in script response.

50

fms.bundle.script.powershell.log.snippet.line.length

Configure the maximum characters per log line after which the log will be truncated.

1024

fms.bundle.script.powershell.upload.chunk.bytes

For inline script, the data is uploaded in chunks and this property is used to configure chunk size.

1024 * 50