WinRM Plugin
The plugin provides functionality to execute commands via WinRM.
Installation
-
Copy the below line to
dependencies
section of the projectbuild.gradle
fileExample 1. build.gradleimplementation(group: 'org.vividus', name: 'vividus-plugin-winrm', version: '0.5.1')
-
If the project was imported to the IDE before adding new plugin, re-generate the configuration files for the used IDE and then refresh the project in the used IDE.
Properties
It’s allowed to configure unlimited number of WinRM connections via mechanism of the dynamic properties. The properties prefix example is:
winrm.server.my-server
where my-server
is a key used to refer WinRm connection in the steps. The key is defined by users, must be unique and can’t contain dots.
The properties marked with bold are mandatory. |
Name | Acceptable values | Default | Description |
---|---|---|---|
|
<string> |
Either full endpoint URL (e.g. |
|
|
<string> |
The name of the user logging in |
|
|
<string> |
The password of the user logging in |
|
|
|
|
Authentication scheme |
|
|
|
Disable/enable HTTPS certificates validation |
Steps
Configure dynamic WinRM connection
Creates a new dynamic WinRM connection from the provided parameters, the connection is available only within the story creating the connection.
When I configure WinRM connection with key `$connectionKey` and parameters:$connectionParameters
-
$connectionKey
- The key to assign to the creating WinRM connection. In case if the key conflicts with a global connection key, the dynamic connection will take precedence within the story. -
$connectionParameters
- The ExamplesTable with WinRM connection parameters.The parameters marked with bold are mandatory.
Name | Acceptable values | Default | Description |
---|---|---|---|
|
<string> |
Either full endpoint URL (e.g. |
|
|
<string> |
The name of the user logging in |
|
|
<string> |
The password of the user logging in |
|
|
|
|
Authentication scheme |
|
|
|
Disable/enable HTTPS certificates validation |
When I configure WinRM connection with key `my-connection` and parameters:
|address |username |password|authentication-scheme|
|10.10.10.10:5985|admin |Pa$$w0rd|Basic |
Execute batch command
Executes a native Windows command. A new session is created on the destination host for each step invocation.
When I execute batch command `$command` on server `$connectionKey` using WinRM and save result to $scopes variable `$variableName`
-
$command
- The batch command limited to 8096 bytes. The maximum length of the command can be even less depending on the platform. -
$connectionKey
- The WinRM connection key matching any of configured ones. -
$variableName
- The variable name to store the command execution results. The the data will be stored under the following keys:-
$variableName.stdout
- the content of the command standard output stream; -
$variableName.stderr
- the content of the command standard error stream; -
$variableName.exit-status
- the exit status (a.k.a exit code) of the command.
-
When I execute batch command `echo hello cmd` on server `my-server` using WinRM and save result as JSON to scenario variable `cmd-result`
Then `${cmd-result.stdout}` is equal to `hello cmd`
Then `${cmd-result.stderr}` is equal to ``
Then `${cmd-result.exit-status}` is equal to `0`
Execute PowerShell command
Executes a PowerShell[https://docs.microsoft.com/en-us/powershell/scripting/overview] command. A new session is created on the destination host for each step invocation.
When I execute PowerShell command `$command` on server `$connectionKey` using WinRM and save result to $scopes variable `$variableName`
-
$command
- The PowerShell command. -
$connectionKey
- The WinRM connection key matching any of configured ones. -
$variableName
- The variable name to store the command execution results. The the data will be stored under the following keys:-
$variableName.stdout
- the content of the command standard output stream; -
$variableName.stderr
- the content of the command standard error stream; -
$variableName.exit-status
- the exit status (a.k.a exit code) of the command.
-
When I execute PowerShell command `echo hello ps` on server `my-server` using WinRM and save result to scenario variable `ps-result`
Then `${ps-result.stdout}` is equal to `hello ps`
Then `${ps-result.stderr}` is equal to ``
Then `${ps-result.exit-status}` is equal to `0`