Run GhostInspector

Octopus.Script exported 2016-06-20 by bobjwalker belongs to ‘Ghost Inspector’ category.

Runs GhostInspector smoke tests asynchronously, returning immediately

Parameters

When steps based on the template are included in a project’s deployment process, the parameters below can be set.

Suite ID

suiteId

Suite ID from Ghostinspector. Can be found in the suite’s URL e.g.: https://app.ghostinspector.com/suites/

Site Base URL

siteUrl

The site’s base URL. All smoke tests will be run starting from this page.

Username

httpAuthUser

The username for use with HTTP Auth (can be left blank for open sites)

Password

httpAuthPass

The password for use with HTTP Auth (can be left blank for open sites)

GhostInspector API Key

apiKey

GhostInspector API key. Can be found here: https://app.ghostinspector.com/account

Script body

Steps based on this template will execute the following PowerShell script.


$ErrorActionPreference = "Stop" 

function Get-Param($Name, [switch]$Required, $Default) {
    $result = $null

    if ($OctopusParameters -ne $null) {
        $result = $OctopusParameters[$Name]
    }

    if ($result -eq $null) {
        $variable = Get-Variable $Name -EA SilentlyContinue   
        if ($variable -ne $null) {
            $result = $variable.Value
        }
    }

    if ($result -eq $null -or $result -eq "") {
        if ($Required) {
            throw "Missing parameter value $Name"
        } else {
            $result = $Default
        }
    }

    return $result
}

& {
    param(
		[string]$suiteId,
		[string]$apiKey,
		[string]$siteUrl,
		[string]$httpAuthUser,
		[string]$httpAuthPass
    ) 

	$apiUrl = "https://api.ghostinspector.com/v1/suites/$suiteId/execute/?immediate=1&apiKey=" + $apiKey

	if(-! ([string]::IsNullOrEmpty($siteUrl)))
	{
		$apiUrl = $apiUrl + '&startUrl=' + $siteUrl
	}
	
	if(-! ([string]::IsNullOrEmpty($httpAuthUser) -and [string]::IsNullOrEmpty($httpAuthPass)))
	{
		$apiUrl = $apiUrl + '&httpAuthUsername=' + $httpAuthUser + '&httpAuthPassword=' + $httpAuthPass
	}

	Write-Output "Invoking API url: $apiUrl" 
	
    try {
		Invoke-WebRequest $apiUrl -UseBasicParsing
    } catch [Exception] {
        Write-Host "There was a problem invoking Url"
        Write-Host $_.Exception|format-list -force;
    }
    Write-Output $("Test Output can be viewed here: https://app.ghostinspector.com/suites/{0} -f $suiteId")

 } `
 (Get-Param 'suiteId' -Required) `
 (Get-Param 'apiKey' - Required) `
 (Get-Param 'siteUrl') `
 (Get-Param 'httpAuthUser') `
 (Get-Param 'httpAuthPass')

Provided under the Apache License version 2.0.

Report an issue

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.

{
  "Id": "8b84e760-a6ca-412c-9b83-1129ca239f32",
  "Name": "Run GhostInspector",
  "Description": "Runs GhostInspector smoke tests asynchronously, returning immediately",
  "Version": 8,
  "ExportedAt": "2016-06-20T06:48:33.000+00:00",
  "ActionType": "Octopus.Script",
  "Author": "bobjwalker",
  "Parameters": [
    {
      "Name": "suiteId",
      "Label": "Suite ID",
      "HelpText": "Suite ID from Ghostinspector.  Can be found in the suite's URL e.g.: \nhttps://app.ghostinspector.com/suites/<suiteID>",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "siteUrl",
      "Label": "Site Base URL",
      "HelpText": "The site's base URL.  All smoke tests will be run starting from this page.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "httpAuthUser",
      "Label": "Username",
      "HelpText": "The username for use with HTTP Auth (can be left blank for open sites)",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "httpAuthPass",
      "Label": "Password",
      "HelpText": "The password for use with HTTP Auth (can be left blank for open sites)",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "Sensitive"
      }
    },
    {
      "Name": "apiKey",
      "Label": "GhostInspector API Key",
      "HelpText": "GhostInspector API key.  Can be found here: https://app.ghostinspector.com/account",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.Syntax": "PowerShell",
    "Octopus.Action.Script.ScriptBody": "\n$ErrorActionPreference = \"Stop\" \n\nfunction Get-Param($Name, [switch]$Required, $Default) {\n    $result = $null\n\n    if ($OctopusParameters -ne $null) {\n        $result = $OctopusParameters[$Name]\n    }\n\n    if ($result -eq $null) {\n        $variable = Get-Variable $Name -EA SilentlyContinue   \n        if ($variable -ne $null) {\n            $result = $variable.Value\n        }\n    }\n\n    if ($result -eq $null -or $result -eq \"\") {\n        if ($Required) {\n            throw \"Missing parameter value $Name\"\n        } else {\n            $result = $Default\n        }\n    }\n\n    return $result\n}\n\n& {\n    param(\n\t\t[string]$suiteId,\n\t\t[string]$apiKey,\n\t\t[string]$siteUrl,\n\t\t[string]$httpAuthUser,\n\t\t[string]$httpAuthPass\n    ) \n\n\t$apiUrl = \"https://api.ghostinspector.com/v1/suites/$suiteId/execute/?immediate=1&apiKey=\" + $apiKey\n\n\tif(-! ([string]::IsNullOrEmpty($siteUrl)))\n\t{\n\t\t$apiUrl = $apiUrl + '&startUrl=' + $siteUrl\n\t}\n\t\n\tif(-! ([string]::IsNullOrEmpty($httpAuthUser) -and [string]::IsNullOrEmpty($httpAuthPass)))\n\t{\n\t\t$apiUrl = $apiUrl + '&httpAuthUsername=' + $httpAuthUser + '&httpAuthPassword=' + $httpAuthPass\n\t}\n\n\tWrite-Output \"Invoking API url: $apiUrl\" \n\t\n    try {\n\t\tInvoke-WebRequest $apiUrl -UseBasicParsing\n    } catch [Exception] {\n        Write-Host \"There was a problem invoking Url\"\n        Write-Host $_.Exception|format-list -force;\n    }\n    Write-Output $(\"Test Output can be viewed here: https://app.ghostinspector.com/suites/{0} -f $suiteId\")\n\n } `\n (Get-Param 'suiteId' -Required) `\n (Get-Param 'apiKey' - Required) `\n (Get-Param 'siteUrl') `\n (Get-Param 'httpAuthUser') `\n (Get-Param 'httpAuthPass')",
    "Octopus.Action.Script.ScriptSource": "Inline",
    "Octopus.Action.Script.ScriptFileName": null,
    "Octopus.Action.Package.NuGetFeedId": null,
    "Octopus.Action.Package.NuGetPackageId": null
  },
  "Category": "Ghost Inspector",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/ghostinspector-runsuite.json",
  "Website": "/step-templates/8b84e760-a6ca-412c-9b83-1129ca239f32",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA9QTFRFiYmJ////yMjIqamp6OjoCSpfGQAABSpJREFUeNrsndua6yAIRgnw/s+8O92d1LZJVfhRMx+5matJs+RkOBja/shFCZIgCZIgCZIgCZIgCZIgCZIgCZIgCZIgCZIgCfIHQVT5fqnqZUFuCCL0vOSGcz0QZTq8RK8Eoix0ekmoXKAgTJWLLwFSxbhLZXkQFXqz78f1avhhQkGBaPms+o0yyOoJrVYnz6kcTIIBkZaHlFD1IiRHZa01koSAHPU4sQtFVwSRjofjMBJC2XmjCe8ky4Fwpyv6JZHFQLTbpXKMwdNojieJrgTClmcKUS5CCKRXSyKUywcitqXlAJEQQLHMoYdXARHr4yg+mLjuZVcQvEhohkAiREJegZDLvHgFEPU8iqIdF3k1S13ixIV3mqNZeN0ip2aJcx1kFRB2aiZMt+wg7PSfYN1ygng0A6tbE0EEGhPJ9xwexWCokUwEUaiRTATZ/hiIXB8Eau0zQaDWPhMEugOeCoLcpcwEge5SnCCCAJHLSwSZqZu413qKhC4P8jUN/NuW81PpXh6ED6uPP105vY0GU429LMDzLgYRS1MO1X/qcePbX+Z3rXA7nKLR4HZ/EXP3B7Wu2PPX7hqrAvKcLR0sLakjsvzKTTQ4x/mNRERKIakVpL5aiFCmckRQuCptKaCSiwPzUvTWriafHWpa/z1q4Li3LPFBcxwuc/vfV4mcddlpVbmo9t5Tur03GnSp3LW/pIpj/HDfux4IbyOv2tpRRSAnkh7UzPshEgOIDteeJhA1gugyIFqx9grIdn0QXhOEbSCSIFH+N0FStdYCoQRZLSCuE9nZB7KOkZBv00iLaZZ9G3/bbk7Yswe8WI0ZWfsmijL75HnVpbkqJncxqHje2ZWmy+Q9U2TLoixAIu1pNNpaSeJHCasc5kzjdjToOU402rOGNStm+ciQRwdJvufp9GPo15WNPzS5EQGjMxffWuiRnluiOR7ltw0B8ubAXoNVpFm0L1uznpTT9rflKTKnGiqQ1ruTd8GwfsxegCGIKXKQZnXct9cFCZrkpzKymzK/2HfXTcktfF9weR16FfvNyP7TCJnwS4XVM9jXD1KER2FxRheBSZdMal1EKHUFfDHEcBzIycMwCMSmpMh5dgyI0W0gTxhg+3/6HTmmd8Gs3L9pt33Pbt7wYPbk5uZEhe2nQS8X1sZXXKM/9lwUsa7AMiBme18OxNoeDuuPh72AG/d7MCPBZRKMLhiVmcGBGO0dZSTIQWwTCarRHwhijO8g3UJm22zvRSDdQoKoyXOBdAua/1SLmeiCILZzgTDJMXBG2mImmBM5wCBqeO/GDL+hawQWEkiSH17s4P6EMMRv4as2/YezKUIkAeUn6ZaJrAnSf/QfwtxDCoLdMgHoVgiI9pIARkSDSrS9R2T6RRIE8jGWFy6SsKJ5H4nfA8edGy9dtVK3SALbGLpI3CIJBCmaSbgde0GQsvpRF4rKAmWFeoxv0BnnEafBzYraIRSZX7HCkPD0GmKrodQW2yWSAX2w2t4FN7jO7hHKV1v2KNeYzmRubIoSu+ca1GL90hZ5jqJ2MxnWK85NrWpqNpOBTe/SgmIOiyO797nlVA0xZlDHjiFwvRnSuucaPU8h1Q8QGc80Hj8YIrWDW2yJxwkTLp9funqVi8pFQA5PQim/PnYdkO14oONxIorQlUBOUOwdgTMHDZXNRx6tBbJ9+zhc7yZl/ujn8aFai0f2drmsvGmswBRntllO88lvhiZIgiRIgiRIgiRIgiRIgiRIgiRIgiRIgiRIgiRIguzXPwEGAKLal+tF3ffMAAAAAElFTkSuQmCC",
  "$Meta": {
    "Type": "ActionTemplate"
  }
}

History

Page updated on Monday, June 20, 2016