Git Product home page Git Product logo

octopus-cmdlets's Introduction

Octopus-Cmdlets

Build status

Yo Dawg, I herd you like automation, so I put cmdlets in your PowerShell so you can automate while you automate.

Octopus-Cmdlets is a suite of PowerShell cmdlets that enable you to simplify and automate your interactions with an Octopus Deploy server.

Note

The module name has changed from Octopus.Cmdlets to Octopus-Cmdlets. Please adjust your process (and scripts) accordingly.

Installation

Powershell Gallery (preferred method)

Install-Module -Name Octopus-Cmdlets

Binary Archive

Download the latest binary: v0.7.0

Extract the zip and copy the Octopus-Cmdlets folder into a folder in your $env:PSModulePath.

Alternatively, you can copy the extracted folder to wherever you like and add the full path to your $env:PSModulePath.

psake

  • Option 1:

    • Open the solution in Visual Studio and build it (this will restore the psake nuget package).

    • Open the Package Manager Console and run:

      psake install

  • Option 2 (if you have psake):

    • Open a prompt in the solution folder and type psake install
  • Option 3 (if psake has already been restored):

    • Open a PowerShell prompt in the solution folder and type

    packages\psake.[version]\tools\psake.ps1 install

Usage

Import-Module Octopus-Cmdlets

Please see the wiki for a description of the individual cmdlets, or type help [cmdlet] from PowerShell.

Licence

Copyright 2018 Colin Svingen

Licensed under the Apache License, Version 2.0

octopus-cmdlets's People

Contributors

ryangribble avatar swoogan avatar vojtech-vit-deltatre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

octopus-cmdlets's Issues

Timeout with Update-Variable, but not Get-Variable

I'm wondering if you have any idea why I would see this error below. I've been using Get-Variable all day, but Update-Variable hasn't ever worked. (Started using these cmdlets today for the first time!)

  • I've tried with other variables (in other projects), but the Update-Variable cmdlet always times out.
  • I tried with a new server connection, but as you can see in the image below, I can run Get-Variable right after, and that one works, so I don't believe it's the connection.
  • I tried with only -Project and -Id (and -Value) parameters (which I thought was the minimum), but that results in 'Bad Parameter Set' error, so I'm using them all, per the examples.

Any thoughts would be appreciated. Maybe I'm doing something wrong here!

Windows PowerShell 2019-06-11 14 59 09

Connect-OctoServer powersell connection not maintained

Looks like “Connect-OctoServer” does not work if calls are done between ps1 file and psm1 module, is that expected?

Using Octopus-CmdLets 0.4.4 and Powershell 5.1

Test.psm1

function Get-EnvironmentViaModule()
{
    "getting all environments..."
    Get-OctoEnvironment
}
Test.ps1

Import-Module .\Test.psm1

$ApiKey = "API-xxxx"
$Url = "https://octopus.xxx.com" 
Connect-OctoServer -Server $Url -ApiKey $ApiKey
"connected..."
Get-EnvironmentViaModule # this fails - but a direct "Get-OctoEnvironment" works

Execution:

> .\Test.ps1
connected...
getting all environments...
Get-OctoEnvironment : Connection not established. Please connect to your Octopus Deploy instance with
Connect-OctoServer
At C:\Users\andrew\Test.psm1:4 char:5
+     Get-OctoEnvironment
+     ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-OctoEnvironment], Exception
    + FullyQualifiedErrorId : System.Exception,Octopus_Cmdlets.GetEnvironment

Add-OctoVariable Throws Error

Thanks a lot for your submission. I have used this to automate synchronization between two Octopus instances (along with using Octopus Tools).

Add-OctoVariable throws an error when Steps parameter is not specified: null reference exception. Here is an example of my powershell script:

Add-OctoVariable -Project "Trend Reporting" -Name "TestVariable" -Value "TestValue"

I believe this is caused by the LINQ statement in file 'AddVariable.cs' on line 174 in the 'AddSteps' method.

Adding a one line 'guard' to this method resolves the problem:
if (Steps == null){ return; }

Note: I have also locally applied this change to the 'AddMachines' and 'AddEnvironments' methods.

Hope that helps -

Is there any way to get only a variable value to json file, using Get-OctoVariable ?

Hi Swoogan.

Sorry for writing you here, but can you hint me - is there any way to get only variable value using Get-OctoVariable from particular environment?

I used command:
Get-OctoVariable myproject myvarAPIJson | Where-Object { $_.Environment -eq "DEV" } | Export-Csv -Path c:\DataAPIJson.csv

But it grabs all, including variable name, value and a bunch of parameters.
Can I get only value to JSON file?

Copy Step between projects

Hey

Thanks, Helps a lot !!!
Wondering if there is possibility to copy step between Projects

Many Thanks

Add-octomachine erroring

Hi

These cmdlets are great but I'm having troubles with add-octomachine.

I’m running this line

Add-octoMachine -environment $environment -Name $Server -endpoint TentacleActive -Roles $roles

And getting this error

Add-OctoMachine : Cannot bind parameter 'Endpoint'. Cannot convert the "TentacleActive" value of type "System.String"

to type "Octopus.Client.Model.Endpoints.EndpointResource".

At C:\serverbuilds\OCTAddEnvironments.ps1:45 char:69

  • ... ironment $environment -Name $Server -endpoint TentacleActive -Roles ...

  • 
    
  • CategoryInfo : InvalidArgument: (:) [Add-OctoMachine], ParameterBindingException

  • FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Octopus_Cmdlets.AddMachine

Any Ideas?

Cheers

Get-OctoVariable gets just project variables not all of them

Hello,
I need to get all the variables from a project.
Get-OctoVariable returns me just Project-Variables, no Templates, no Sets.
I use this command: Get-OctoVariable -Project ProjectName
Is there a way to get all the variables from a project?

Add-Variable with scope restrictions not working

Octopus Server version: 3.5.2

Example command:
Add-OctoVariable -Project API -Name TEST -Value TEST -Steps Deploy -Environments QA

This is creating a variable named TEST, with the value TEST in the QA environment. However, it's not being scoped to the step named 'Deploy'

Get-Variable already available error when installing

Hi,

I am getting the following error when installing Octopus-Cmdlets.

PackageManagement\Install-Package : A command with name 'Get-Variable' is already available on this
system. This module 'Octopus-Cmdlets' may override the existing commands. If you still want to install
this module 'Octopus-Cmdlets', use -AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21

  • ... $null = PackageManagement\Install-Package @PSBoundParameters
  •                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Ins
      tall-Package], Exception
    • FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.
      PowerShell.PackageManagement.Cmdlets.InstallPackage

Copying sensitive variables throws exception

Get-OctoVariable "project" | ? {$_.Name -like "IIS.AppPool*"}  | Add-OctoLibraryVariable "variableset"
Add-OctoLibraryVariable : Octopus Server returned an error: String reference not set to an instance of a String.
Parameter name: s
Server exception:
System.ArgumentNullException: String reference not set to an instance of a String.
Parameter name: s
   at System.Text.Encoding.GetBytes(String s)
   at Octopus.Platform.Security.MasterKey.MasterKeyEncryptionExtensions.StringToCiphertext(IMasterKeyEncryption
encryption, String plaintext) in
y:\work\refs\heads\release\source\Octopus.Platform\Security\MasterKey\MasterKeyEncryptionExtensions.cs:line 13
   at Octopus.Server.Web.Api.Actions.VariableSetUpdateAction.Execute() in
y:\work\refs\heads\release\source\Octopus.Server\Web\Api\Actions\VariableSetUpdateAction.cs:line 100
   at Octopus.Platform.Web.Api.Responder`1.Respond(TDescriptor options, NancyContext context) in
y:\work\refs\heads\release\source\Octopus.Platform.Web\Api\Responder.cs:line 163
   at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at CallSite.Target(Closure , CallSite , Object , Object , NancyContext )
   at Octopus.Server.Web.Api.OctopusRestApiModule.<>c__DisplayClass5.<.ctor>b__2(Object o) in
y:\work\refs\heads\release\source\Octopus.Server\Web\Api\OctopusRestApiModule.cs:line 47
   at CallSite.Target(Closure , CallSite , Func`2 , Object )
   at Nancy.Routing.Route.<>c__DisplayClass4.b__3(Object parameters, CancellationToken context)
-----------------------
At line:1 char:69
+ Get-OctoVariable "d2d server" | ? {$_.Name -like "IIS.AppPool*"}  | Add-OctoLibr ...
+                                                                     ~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-OctoLibraryVariable], OctopusServerException
    + FullyQualifiedErrorId : Octopus.Client.Exceptions.OctopusServerException,Octopus.Cmdlets.AddLibraryVariable

Errors in Get-Machine by -Name

I get the following error when using Get-Machine (I import using an 'Octo-' prefix) using MachineName. Using an Id works fine.

Get-OctoMachine -Id Machines-82 works fine.

Get-OctoMachine -Name 'Server1' gives:

Get-OctoMachine : Error converting value "CalamariNeedsUpgrade" to type 
'Octopus.Client.Model.MachineModelStatus'. Path 'Items[0].Status', line 22, position 39.
At line:1 char:1
+ Get-OctoMachine Server1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-OctoMachine], JsonSerializationException
    + FullyQualifiedErrorId : Newtonsoft.Json.JsonSerializationException,Octopus_Cmdlets.GetMachine

Ps: The PowerShell Gallery version is still 0.1.0

Feature Request - Adding -Sensitive parameter to Add-OctoLibraryVariable

There are two Add-OctoLibraryVariable commands that this project supports:

# Method 1
Add-OctoLibraryVariable [-VariableSet] <string> [-InputObject] <VariableResource[]>  [<CommonParameters>]

# Method 2
Add-OctoLibraryVariable [-VariableSet] <string> [-Name] <string> [[-Value] <string>] [-Environments <string[]>] [-Roles <string[]>] [-Machines <string[]>] [-Sensitive]  [<CommonParameters>]

I am trying to bulk copy variables (including sensitive ones) from a project to a variable set. For this purpose I am using Method 1 above, however, it doesn't currently support the -Sensitive flag.

Just raising it as a feature request to add to this project.

Octopus-Cmdlets\Octopus-Cmdlets.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

PS C:\Windows\system32> Import-Module Octopus-Cmdlets
Import-Module : Could not load file or assembly
'file:///C:\Users\mukhin_s\Documents\WindowsPowerShell\Modules\Octopus-Cmdlets\Octopus-Cmdlets.dll' or one of its
dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At line:1 char:1

  • Import-Module Octopus-Cmdlets
  • - CategoryInfo          : NotSpecified: (:) [Import-Module], FileLoadException
    - FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand
    
    

Tried with both 0.1.0 and 0.2.24 versions.

PS C:\Windows\system32> $PSVersionTable.PSVersion
Major Minor Build Revision


4 0 -1 -1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.