Skip to content

Instantly share code, notes, and snippets.

@abelevtsov
Created November 30, 2016 11:12
Show Gist options
  • Save abelevtsov/355e912afc15d74dbb3fa21489f2781d to your computer and use it in GitHub Desktop.
Save abelevtsov/355e912afc15d74dbb3fa21489f2781d to your computer and use it in GitHub Desktop.

Revisions

  1. abelevtsov created this gist Nov 30, 2016.
    27 changes: 27 additions & 0 deletions PostDeployCrmPlugins_Octopus.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    $environment = $OctopusParameters["Octopus.Environment.Name"]
    $buildPath = $OctopusParameters["BuildPath"]
    $apiuri = $OctopusParameters["PluginRegistrationServiceUrl"]

    Write-Output "Publish Plugins to $environment"

    $start_time = Get-Date

    $mergedPluginAssemblyPath = "$buildPath\Sk.Crm.Plugins.dll"
    $mergedPluginAssemblyPath = $mergedPluginAssemblyPath -replace "\\", "\\"

    $configPath = "$buildPath\RegisterFile.crmregister"
    $configPath = $configPath -replace "\\", "\\"

    $data = @"
    {
    "mergedPluginAssemblyPath": "$mergedPluginAssemblyPath",
    "configPath": "$configPath",
    "environment": "$environment"
    }
    "@

    Write-Output $data

    Invoke-WebRequest -Uri $apiuri -Method POST -Body $data -ContentType "application/json"

    Write-Output "Plugins published successfully, time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"