Downloads:

9,221

Downloads of v 0.0.28:

330

Last Update:

21 Mar 2015

Package Maintainer(s):

Software Author(s):

  • Chris Dostert

Tags:

Powershell PoshDevOps TaskRunner CI ContinuousIntegration Build Deployment admin

PoshDevOps

This is not the latest version of PoshDevOps available.

  • 1
  • 2
  • 3

0.0.28 | Updated: 21 Mar 2015

Downloads:

9,221

Downloads of v 0.0.28:

330

Maintainer(s):

Software Author(s):

  • Chris Dostert

  • 1
  • 2
  • 3
PoshDevOps 0.0.28

This is not the latest version of PoshDevOps available.

  • 1
  • 2
  • 3

Some Checks Have Failed or Are Not Yet Complete

Not All Tests Have Passed


Validation Testing Unknown


Verification Testing Unknown


Scan Testing Successful:

No detections found in any package files

Details

To install PoshDevOps, run the following command from the command line or from PowerShell:

>

To upgrade PoshDevOps, run the following command from the command line or from PowerShell:

>

To uninstall PoshDevOps, run the following command from the command line or from PowerShell:

>

NOTE: This applies to both open source and commercial editions of Chocolatey.

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

  • Open Source or Commercial:
    • Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://community.chocolatey.org/api/v2. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
    • You can also just download the package and push it to a repository Download

3. Enter your internal repository url

(this should look similar to https://community.chocolatey.org/api/v2)

4. Choose your deployment method:


choco upgrade poshdevops -y --source="'STEP 3 URL'" [other options]

See options you can pass to upgrade.

See best practices for scripting.

Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.

If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:


choco upgrade poshdevops -y --source="'STEP 3 URL'"
$exitCode = $LASTEXITCODE

Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
  Exit 0
}

Exit $exitCode

- name: Ensure poshdevops installed
  win_chocolatey:
    name: poshdevops
    state: present
    version: 0.0.28
    source: STEP 3 URL

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.


chocolatey_package 'poshdevops' do
  action    :install
  version  '0.0.28'
  source   'STEP 3 URL'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


Chocolatey::Ensure-Package
(
    Name: poshdevops,
    Version: 0.0.28,
    Source: STEP 3 URL
);

Requires Otter Chocolatey Extension. See docs at https://inedo.com/den/otter/chocolatey.


cChocoPackageInstaller poshdevops
{
   Name     = 'poshdevops'
   Ensure   = 'Present'
   Version  = '0.0.28'
   Source   = 'STEP 3 URL'
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'poshdevops':
  provider => 'chocolatey',
  ensure   => '0.0.28',
  source   => 'STEP 3 URL',
}

Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.


salt '*' chocolatey.install poshdevops version="0.0.28" source="STEP 3 URL"

See docs at https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.chocolatey.html.

5. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

This package was approved as a trusted package on 24 Apr 2015.

Description

PowerShell driven distributed DevOps

Installation notes:
- installs to: C:\ProgramFiles\PoshDevOps
- appends C:\ProgramFiles\PoshDevOps\Modules to PSModulePath environment variable


tools\.git\config
 
tools\.git\description
 
tools\.git\HEAD
 
tools\.git\hooks\applypatch-msg.sample
 
tools\.git\hooks\commit-msg.sample
 
tools\.git\hooks\post-update.sample
 
tools\.git\hooks\pre-applypatch.sample
 
tools\.git\hooks\pre-commit.sample
 
tools\.git\hooks\pre-push.sample
 
tools\.git\hooks\pre-rebase.sample
 
tools\.git\hooks\prepare-commit-msg.sample
 
tools\.git\hooks\update.sample
 
tools\.git\index
 
tools\.git\info\exclude
 
tools\.git\logs\HEAD
 
tools\.git\logs\refs\heads\master
 
tools\.git\logs\refs\remotes\origin\HEAD
 
tools\.git\objects\pack\pack-1885550a95e8c57dac68ccb2f8a231c974f739da.idx
 
tools\.git\objects\pack\pack-1885550a95e8c57dac68ccb2f8a231c974f739da.pack
 
tools\.git\packed-refs
 
tools\.git\refs\heads\master
 
tools\.git\refs\remotes\origin\HEAD
 
tools\.gitignore
 
tools\.PoshDevOps\Packages\CreateChocolateyPackage.0.0.19\tools\CreateChocolateyPackage\CreateChocolateyPackage.psm1
# halt immediately on any errors which occur in this module
$ErrorActionPreference = "Stop"

function EnsureChocolateyInstalled(
[String]
[ValidateNotNullOrEmpty()]
$PathToChocolateyExe){
    # install chocolatey
    try{
        Get-Command $PathToChocolateyExe -ErrorAction Stop | Out-Null
    }
    catch{             
        iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
    }   
}

function Invoke-PoshDevOpsTask(

[String]
[ValidateNotNullOrEmpty()]
[Parameter(
    Mandatory=$true,
    ValueFromPipelineByPropertyName=$true)]
$PoshDevOpsProjectRootDirPath,

[String[]]
[ValidateCount(1,[Int]::MaxValue)]
[Parameter(
    ValueFromPipelineByPropertyName = $true)]
$IncludeNuspecPath = @(gci -Path $PoshDevOpsProjectRootDirPath -File -Filter '*.nuspec' -Recurse | %{$_.FullName}),

[String[]]
[Parameter(
    ValueFromPipelineByPropertyName = $true)]
$ExcludeNuspecNameLike,

[Switch]
[Parameter(
    ValueFromPipelineByPropertyName=$true)]
$Recurse,

[String]
[Parameter(
    ValueFromPipelineByPropertyName=$true)]
$OutputDirectoryPath,

[String]
[Parameter(
    ValueFromPipelineByPropertyName = $true)]
$Version,

[String]
[ValidateNotNullOrEmpty()]
[Parameter(
    ValueFromPipelineByPropertyName=$true)]
$PathToChocolateyExe = 'C:\ProgramData\chocolatey\bin\chocolatey.exe'){

    EnsureChocolateyInstalled -PathToChocolateyExe $PathToChocolateyExe

    $NuspecFilePaths = gci -Path $IncludeNuspecPath -Filter '*.nuspec' -File -Exclude $ExcludeNuspecNameLike -Recurse:$Recurse | ?{!$_.PSIsContainer} | %{$_.FullName}

Write-Debug `
@"
`Located .nuspec's:
$($NuspecFilePaths | Out-String)
"@

    if($OutputDirectoryPath){
        Push-Location ( Resolve-Path $OutputDirectoryPath)        
    }
    else{            
        Push-Location (Get-Location)       
    }

Write-Debug  `
@"
output directory is:
$OutputDirectoryPath
"@

    foreach($nuspecFilePath in $NuspecFilePaths)
    {
    
        $chocolateyParameters = @('pack',$nuspecFilePath)
        
        if($Version){
            $chocolateyParameters += @('-version',$Version)
        }

Write-Debug `
@"
Invoking choco:
& $PathToChocolateyExe $($chocolateyParameters|Out-String)
"@
        & $PathToChocolateyExe $chocolateyParameters

        # handle errors
        if ($LastExitCode -ne 0) {
            throw $Error
        }
    }

    # revert location
    Pop-Location
}

Export-ModuleMember -Function Invoke-PoshDevOpsTask 
tools\.PoshDevOps\Packages\CreateChocolateyPackage.0.0.21\tools\CreateChocolateyPackage\CreateChocolateyPackage.psm1
# halt immediately on any errors which occur in this module
$ErrorActionPreference = "Stop"

function EnsureChocolateyInstalled(
[String]
[ValidateNotNullOrEmpty()]
$PathToChocolateyExe){
    # install chocolatey
    try{
        Get-Command $PathToChocolateyExe -ErrorAction Stop | Out-Null
    }
    catch{             
        iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
    }   
}

function Invoke-PoshDevOpsTask(

[String]
[ValidateNotNullOrEmpty()]
[Parameter(
    Mandatory=$true,
    ValueFromPipelineByPropertyName=$true)]
$PoshDevOpsProjectRootDirPath,

[String[]]
[ValidateCount(1,[Int]::MaxValue)]
[Parameter(
    ValueFromPipelineByPropertyName = $true)]
$IncludeNuspecPath = @(gci -Path $PoshDevOpsProjectRootDirPath -File -Filter '*.nuspec' -Recurse | %{$_.FullName}),

[String[]]
[Parameter(
    ValueFromPipelineByPropertyName = $true)]
$ExcludeNuspecNameLike,

[Switch]
[Parameter(
    ValueFromPipelineByPropertyName=$true)]
$Recurse,

[String]
[Parameter(
    ValueFromPipelineByPropertyName=$true)]
$OutputDirectoryPath,

[String]
[Parameter(
    ValueFromPipelineByPropertyName = $true)]
$Version,

[String]
[ValidateNotNullOrEmpty()]
[Parameter(
    ValueFromPipelineByPropertyName=$true)]
$PathToChocolateyExe = 'C:\ProgramData\chocolatey\bin\chocolatey.exe'){

    EnsureChocolateyInstalled -PathToChocolateyExe $PathToChocolateyExe

    $NuspecFilePaths = gci -Path $IncludeNuspecPath -Filter '*.nuspec' -File -Exclude $ExcludeNuspecNameLike -Recurse:$Recurse | ?{!$_.PSIsContainer} | %{$_.FullName}

Write-Debug `
@"
`Located .nuspec's:
$($NuspecFilePaths | Out-String)
"@

    if($OutputDirectoryPath){
        Push-Location ( Resolve-Path $OutputDirectoryPath)        
    }
    else{            
        Push-Location (Get-Location)       
    }

Write-Debug  `
@"
output directory is:
$OutputDirectoryPath
"@

    foreach($nuspecFilePath in $NuspecFilePaths)
    {
    
        $chocolateyParameters = @('pack',$nuspecFilePath)
        
        if($Version){
            $chocolateyParameters += @('-version',$Version)
        }

Write-Debug `
@"
Invoking choco:
& $PathToChocolateyExe $($chocolateyParameters|Out-String)
"@
        & $PathToChocolateyExe $chocolateyParameters

        # handle errors
        if ($LastExitCode -ne 0) {
            throw $Error
        }
    }

    # revert location
    Pop-Location
}

Export-ModuleMember -Function Invoke-PoshDevOpsTask 
tools\.PoshDevOps\TaskGroup.psd1
 
tools\Docs\DesignGuidelines.md
#Project Guidelines

##Feature Design
When designing features:

1.	All features must support both interactive and non-interactive consumption via PowerShell. 


##Development

####1 General
#####1.1 Follow MSDN Guidelines
PowerShell usage must be consistent with, [MSDN guidelines](https://msdn.microsoft.com/en-us/library/dd835506(v=vs.85).aspx). (some useful links within those guidelines are: [Module Installation](https://msdn.microsoft.com/en-us/library/dd878350%28v=vs.85%29.aspx), [Command naming](https://msdn.microsoft.com/en-us/library/ms714428%28v=vs.85%29.aspx), [Standard Cmdlet parameter Names and Types](https://msdn.microsoft.com/en-us/library/dd878352(v=vs.85).aspx)

####2 CI-Tasks
#####2.1 Use string[] For Parameters Being Passed To Things Outside Powershell
When defining a DevOps task, if a parameter will be used asa pass-through to something outside Powershell (example: invoking a .exe), make the parameter of type string[]. For a great background on why see [powershell-call-operator-using-an-array-of-parameters-to-solve-all-your-quoting-problems](https://com2kid.wordpress.com/2011/09/25/powershell-call-operator-using-an-array-of-parameters-to-solve-all-your-quoting-problems/)
tools\Docs\Index.md
* [QuickStart](./QuickStart.md)
tools\Docs\QuickStart.md
From your source root:
```PowerShell
PoshDevOps\New-Build
```
tools\Docs\Variables.md
###1 Configurable Parameters
When developing a DevOps task that requires/allows configuration, add parameters to your Invoke-PoshDevOpsTask method signature with type `string` and any desired name (excluding names beginning with PoshDevOps which is reserved for Automatic Parameters).

Example:
```PowerShell
function Invoke-PoshDevOpsTask(
[string][Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]$CustomParam1,
[string][Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]$CustomParam2)
{
    # implementation snipped...
}

```

###2 Automatic Parameters
PoshDevOps will automatically populate certain DevOps task parameters, the names of which always start with the prefix `PoshDevOps`.
These parameters provide information about the executing task group/DevOps task. 

To use automatic parameters, add parameters matching the type and name of defined automatic parameters to your Invoke-PoshDevOpsTask method signature and PoshDevOps will populate them at invocation time.

Example:
```PowerShell
function Invoke-PoshDevOpsTask(
[string][Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]$PoshDevOpsProjectRootDirPath,
[string][Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]$PoshDevOpsTaskName)
{
    # implementation snipped...
}

```

#####2.1 [string]$PoshDevOpsProjectRootDirPath
Always available;equals the project root dir path of the currently executing task group

#####2.2 [string]$TaskName
Always available;equals the name of the currently executing DevOps task
tools\LICENSE
 
tools\README.md
###What problems does PoshDevOps attempt to solve?

Build/Deployment services today are extremely powerfull and easy to use. However, if you throw your DevOps together in most of these services you are left with: 
######-1 lack of versioning side by side source code 
######-2 coupling of implementation to a proprietary build/deployment service.
######-3 no capability to run outside of a proprietary build/deployment
######-4 expenses (subscriptions, licenses, hardware,  etc...)
######-5 one off scripts lacking any any sort of modularity
######-6 rampant copying/pasting, general lack of reuse

###How does PoshDevOps attempt to solve them?
######+1 versioning side by side source code
######+2 implemented as plain old PowerShell modules
######+3 ability to run anything capable of running PowerShell
######+4 no expenses (as long as you have something capable of running PowerShell ;))
######+5 all tasks are implemented as PowerShell modules
######+6 all tasks are package sourced and inherently reuseable

###How do I install it?
Make sure you have [Chocolatey](https://chocolatey.org) installed, then from PowerShell run
```POWERSHELL
choco install poshdevops -version 0.0.27; # 0.0.27 was latest at time of writing
Import-Module "C:\Program Files\PoshDevOps\Modules\PoshDevOps" -Force
```
###In a nutshell, hows it work?
***Conceptually:***
- `task groups` contain an ordered set of tasks
- `tasks` are arbitrary operations implemented as PowerShell modules and packaged as .nupkg's.

***Operationally:***
- everything takes place within PowerShell
- as you [CRUD](http://en.wikipedia.org/wiki/Create,_read,_update_and_delete) each `task group` a snapshot is maintained in a `TaskGroup.psd1` file.
- at any time you can invoke your `task group` and pass in any parameters your `tasks` rely on

###How do I get started?
navigate to the root directory of your project:
```POWERSHELL
Set-Location "PATH-TO-ROOT-DIR-OF-YOUR-PROJECT"
```
create a new task group:
```POWERSHELL
New-PoshDevOpsTaskGroup
```
add a task to your plan:
```POWERSHELL
Add-PoshDevOpsTask -Name "Compile" -ModulePath "PATH-TO-DIR-CONTAINING-MODULE"
```
invoke your task group:
```POWERSHELL
@{[email protected]{Var1='Value1';Var2='Value2'}} | Invoke-PoshDevOpsTaskGroup
```

###How do I distribute my task group?
When you run `New-PoshDevOpsTaskGroup` it creates a folder named `.PoshDevOps` at the root of your project. From then on all modifications to your task groups are maintained inside that folder so your .PoshDevOps folder is all you need!

(pro-tip: check your .PoshDevOps folder in to source control to version your task group along with your code.)

###Where's the documentation?
[Here](Docs)

###What's the build status
![](https://ci.appveyor.com/api/projects/status/jt0ppwagy4kmreap?svg=true)

###Interesting reading
[Distributed Continuous Integration - Keep the Mainline Clean](http://blog.assembla.com/AssemblaBlog/tabid/12618/bid/96937/Distributed-Continuous-Integration-Keep-the-Mainline-Clean.aspx)

tools\Src\chocolateyInstall.ps1
try {    
    
    . "$PSScriptRoot\Install.ps1"

} catch {

    Write-ChocolateyFailure 'PoshDevOps' $_.Exception.Message

    throw 
}
tools\Src\chocolateyUninstall.ps1
try {

    . "$PSScriptRoot\Uninstall.ps1"

} catch {

    Write-ChocolateyFailure 'PoshDevOps' $_.Exception.Message

    throw 
}
tools\Src\Install.ps1
# installer based on guidelines provided by Microsoft 
# for installing shared/3rd party powershell modules
# (see: https://msdn.microsoft.com/en-us/library/dd878350%28v=vs.85%29.aspx )
if($PSVersionTable.PSVersion.Major -lt 3) {
    Write-Warning "PoshDevOps requires PowerShell 3.0 or better; you have version $($Host.Version)."
    return
}

# prepare install dir
$installRootDirPath = "$env:ProgramFiles\PoshDevOps"
$installDirPath = "$installRootDirPath\Modules"

# handle upgrade scenario
if(Test-Path "$installRootDirPath"){
    Write-Debug 'removing previous PoshDevOps installation'
    . "$PSScriptRoot\Uninstall.ps1"
}
New-Item $installDirPath -ItemType Directory | Out-Null

Copy-Item -Path "$PSScriptRoot" -Destination $installDirPath -Recurse

$psModulePath = [Environment]::GetEnvironmentVariable('PSModulePath','Machine')

# if installation dir path is not already in path then add it.
if(!($psModulePath.Split(';').Contains($installDirPath))){
    Write-Debug "adding $installDirPath to '$env:PSModulePath'"
    
    # trim trailing semicolon if exists
    $psModulePath = $psModulePath.TrimEnd(';');

    # append path to PoshDevOps installation
    $psModulePath = $psModulePath + ";$installDirPath"
    
    # save
    [Environment]::SetEnvironmentVariable('PSModulePath',$psModulePath,'Machine')    
    
    # make effective in current session
    $env:PSModulePath = $env:PSModulePath + ";$installDirPath"
}
tools\Src\PoshDevOps.psm1
Write-Debug "Dot Sourcing $PSScriptRoot\PsonConverters.ps1"
. "$PSScriptRoot\PsonConverters.ps1"

$defaultPackageSources = @('https://www.myget.org/F/poshdevops')

function EnsureNuGetInstalled(){
    try{
        Get-Command nuget -ErrorAction Stop | Out-Null
    }
    catch{
Write-Debug "installing nuget.commandline"
        chocolatey install nuget.commandline | Out-Null
    }
}

function Get-PoshDevOpsTaskGroup(
[string]
[Parameter(
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
    <#
        .SYNOPSIS
        parses a task group file
    #>

    $taskGroupFilePath = Resolve-Path "$ProjectRootDirPath\.PoshDevOps\TaskGroup.psd1"   
Write-Output (Get-Content $taskGroupFilePath | Out-String | ConvertFrom-Pson)

}

function Save-TaskGroup(
[PsCustomObject]
$TaskGroup,

[string]
[Parameter(
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
    <#
        .SYNOPSIS
        an internal utility function to snapshot and save a TaskGroup to disk
    #>
    
    $taskGroupFilePath = Resolve-Path "$ProjectRootDirPath\.PoshDevOps\TaskGroup.psd1"    
    Set-Content $taskGroupFilePath -Value (ConvertTo-Pson -InputObject $TaskGroup -Depth 12 -Layers 12 -Strict)
}

function Get-UnionOfHashtables(
[Hashtable]
[ValidateNotNull()]
[Parameter(
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true)]
$Source1,

[Hashtable]
[ValidateNotNull()]
[Parameter(
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true)]
$Source2){
    $destination = $Source1.Clone()
    Write-Debug "After adding `$Source1, destination is $($destination|Out-String)"

    $Source2.GetEnumerator() | ?{!$destination.ContainsKey($_.Key)} |%{$destination[$_.Key] = $_.Value}
    Write-Debug "After adding `$Source2, destination is $($destination|Out-String)"

    Write-Output $destination
}

function Get-IndexOfKeyInOrderedDictionary(
[string]
[ValidateNotNullOrEmpty()]
$Key,

[System.Collections.Specialized.OrderedDictionary]
[ValidateNotNullOrEmpty()]
$OrderedDictionary){
    <#
        .SYNOPSIS
        an internal utility function to find the index of a key in an ordered dictionary
    #>

    $indexOfKey = -1
    $keysArray = [string[]]$OrderedDictionary.Keys
    for ($i = 0; $i -lt $OrderedDictionary.Count; $i++){
        if($keysArray[$i] -eq $Key){
            $indexOfKey = $i
            break
        }
    }

Write-Output $indexOfKey
}

function Get-LatestPackageVersion(

[string[]]
[Parameter(
    Mandatory=$true)]
$PackageSources = $defaultPackageSources,

[string]
[ValidateNotNullOrEmpty()]
[Parameter(
    Mandatory=$true)]
$PackageId){
    
    $versions = @()

    foreach($packageSource in $PackageSources){
        $uri = "$packageSource/api/v2/package-versions/$PackageId"
Write-Debug "Attempting to fetch package versions:` uri: $uri "
        $versions = $versions + (Invoke-RestMethod -Uri $uri)
Write-Debug "response from $uri was: ` $versions"
    }
    if(!$versions -or ($versions.Count -lt 1)){
throw "no versions of $PackageId could be located.` searched: $PackageSources"
    }

Write-Output ([Array]($versions| Sort-Object -Descending))[0]
}

function Add-PoshDevOpsTask(
[CmdletBinding(
    DefaultParameterSetName="add-TaskLast")]

[string]
[ValidateNotNullOrEmpty()]
[Parameter(
    Mandatory=$true)]
$Name,

[string]
[Parameter(
    Mandatory=$true)]
$PackageId,

[string]
$PackageVersion,

[switch]
[Parameter(
    Mandatory=$true,
    ParameterSetName='add-TaskFirst')]
$First,

[switch]
[Parameter(
    ParameterSetName='add-TaskLast')]
$Last,

[string]
[Parameter(
    Mandatory=$true,
    ParameterSetName='add-TaskAfter')]
$After,

[string]
[Parameter(
    Mandatory=$true,
    ParameterSetName='add-TaskBefore')]
$Before,

[string[]]
$PackageSources=$defaultPackageSources,

[string]
[Parameter(
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){

    <#
        .SYNOPSIS
        Adds a new task to a task group
        
        .EXAMPLE
        Add-PoshDevOpsTask -Name "LastTask" -PackageId "DeployNupkgToAzureWebsites" -PackageVersion "0.0.3"
        
        Description:

        This command adds a task (named LastTask) after all existing tasks

        .EXAMPLE
        Add-PoshDevOpsTask -Name "FirstTask" -PackageId "DeployNupkgToAzureWebsites" -First

        Description:

        This command adds a task (named FirstTask) before all existing tasks

        .EXAMPLE
        Add-PoshDevOpsTask -Name "AfterSecondTask" -PackageId "DeployNupkgToAzureWebsites" -After "SecondTask"

        Description:

        This command adds a task (named AfterSecondTask) after the existing task named SecondTask

        .EXAMPLE
        Add-PoshDevOpsTask -Name "BeforeSecondTask" -PackageId "DeployNupkgToAzureWebsites" -Before "SecondTask"

        Description:

        This command adds a task (named BeforeSecondTask) before the existing task named SecondTask

    #>

    $taskGroup = Get-PoshDevOpsTaskGroup -ProjectRootDirPath $ProjectRootDirPath
    
    if($taskGroup.Tasks.Contains($Name)){

throw "A task with name $Name already exists.`n Tip: You can remove the existing task by invoking Remove-PoshDevOpsTask"
            
    }
    else{
        
        if([string]::IsNullOrWhiteSpace($PackageVersion)){
            $PackageVersion = Get-LatestPackageVersion -PackageSources $PackageSources -PackageId $PackageId
Write-Debug "using greatest available module version : $PackageVersion"
        }


        $key = $Name
        $value = [PSCustomObject]@{'Name'=$Name;'PackageId'=$PackageId;'PackageVersion'=$PackageVersion}

        if($First.IsPresent){
        
            $taskGroup.Tasks.Insert(0,$key,$value)
        
        }
        elseif('add-TaskAfter' -eq $PSCmdlet.ParameterSetName){

            $indexOfAfter = Get-IndexOfKeyInOrderedDictionary -Key $After -OrderedDictionary $taskGroup.Tasks
            # ensure task with key $After exists
            if($indexOfAfter -lt 0){
                throw "A task with name $After could not be found."
            }
            $taskGroup.Tasks.Insert($indexOfAfter + 1,$key,$value)
        
        }
        elseif('add-TaskBefore' -eq $PSCmdlet.ParameterSetName){        
        
            $indexOfBefore = Get-IndexOfKeyInOrderedDictionary -Key $Before -OrderedDictionary $taskGroup.Tasks
            # ensure task with key $Before exists
            if($indexOfBefore -lt 0){
                throw "A task with name $Before could not be found."
            }
            $taskGroup.Tasks.Insert($indexOfBefore,$key,$value)
        
        }
        else{
        
            # by default add as last task
            $taskGroup.Tasks.Add($key, $value)        
        }

Write-Debug "saving task group"
        Save-TaskGroup -TaskGroup $taskGroup -ProjectRootDirPath $ProjectRootDirPath    

    }
}

function Set-PoshDevOpsTaskParameters(

[string]
[ValidateNotNullOrEmpty()]
[Parameter(
    Mandatory=$true)]
$PoshDevOpsTaskName,

[hashtable]
[Parameter(
    Mandatory=$true)]
$Parameters,

[switch]$Force,

[string]
[Parameter(
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
    <#
        .SYNOPSIS
        Sets configurable parameters of a task
        
        .EXAMPLE
        Set-PoshDevOpsTaskParameters -PoshDevOpsTaskName "GitClone" -Parameters @{[email protected]("status")} -Force
        
        Description:

        This command sets a parameter (named "GitParameters") for a task (named "GitClone") to @("status")
    #>

    $taskGroup = Get-PoshDevOpsTaskGroup -ProjectRootDirPath $ProjectRootDirPath
    $ciTask = $taskGroup.Tasks.$PoshDevOpsTaskName
    $parametersPropertyName = "Parameters"

Write-Debug "Checking task `"$PoshDevOpsTaskName`" for property `"$parametersPropertyName`""
    $parametersPropertyValue = $ciTask.$parametersPropertyName    
    if($parametersPropertyValue){
        foreach($parameter in $Parameters.GetEnumerator()){

            $parameterName = $parameter.Key
            $parameterValue = $parameter.Value

Write-Debug "Checking if parameter `"$parameterName`" previously set"
            $previousParameterValue = $parametersPropertyValue.$parameterName
            if($previousParameterValue){
Write-Debug "Found parameter `"$parameterName`" previously set to `"$($previousParameterValue|Out-String)`""
$confirmationPromptQuery = 
@"
For task `"$PoshDevOpsTaskName`",
are you sure you want to change the value of parameter `"$parameterName`"?
    old value: $($previousParameterValue|Out-String)
    new value: $($parameterValue|Out-String)
"@

                $confirmationPromptCaption = "Confirm parameter value change"

                if($Force.IsPresent -or !$PSCmdlet.ShouldContinue($confirmationPromptQuery,$confirmationPromptCaption)){
Write-Debug "Skipping parameter `"$parameterName`". Overwriting existing parameter value was not confirmed."
                    continue
                }
            }
Write-Debug "Setting parameter `"$parameterName`" = `"$($parameterValue|Out-String)`" "
            $parametersPropertyValue.$parameterName = $parameterValue
        }
    }
    else {        
Write-Debug `
@"
Property `"$parametersPropertyName`" has not previously been set for task `"$PoshDevOpsTaskName`"
Adding with value:
$($Parameters|Out-String)
"@
        Add-Member -InputObject $ciTask -MemberType 'NoteProperty' -Name $parametersPropertyName -Value $Parameters -Force
    }
    
    Save-TaskGroup -TaskGroup $taskGroup -ProjectRootDirPath $ProjectRootDirPath
}

function Remove-PoshDevOpsTask(
[string]
[ValidateNotNullOrEmpty()]
[Parameter(
    Mandatory=$true)]
$Name,

[switch]$Force,

[string]
[Parameter(
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){

    $confirmationPromptQuery = "Are you sure you want to delete the task with name $Name`?"
    $confirmationPromptCaption = 'Confirm task removal'

    if($Force.IsPresent -or $PSCmdlet.ShouldContinue($confirmationPromptQuery,$confirmationPromptCaption)){

        $taskGroup = Get-PoshDevOpsTaskGroup -ProjectRootDirPath $ProjectRootDirPath
Write-Debug "Removing task $Name"
        $taskGroup.Tasks.Remove($Name)
        Save-TaskGroup -TaskGroup $taskGroup -ProjectRootDirPath $ProjectRootDirPath
    }

}

function New-PoshDevOpsTaskGroup(
[string]
[Parameter(
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
    $taskGroupDirPath = "$(Resolve-Path $ProjectRootDirPath)\.PoshDevOps"

    if(!(Test-Path $taskGroupDirPath)){    
        $templatesDirPath = "$PSScriptRoot\Templates"

Write-Debug "Creating a directory for the task group at path $taskGroupDirPath"
        New-Item -ItemType Directory -Path $taskGroupDirPath

Write-Debug "Adding default files to path $taskGroupDirPath"
        Copy-Item -Path "$templatesDirPath\TaskGroup.psd1" $taskGroupDirPath
    }
    else{        
throw ".PoshDevOps directory already exists at $taskGroupDirPath. If you are trying to recreate your task group from scratch you must invoke Remove-PoshDevOpsTaskGroup first"
    }
}

function Remove-PoshDevOpsTaskGroup(
[switch]$Force,
[string]
[Parameter(
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath = '.'){
    
    $taskGroupDirPath = Resolve-Path "$ProjectRootDirPath\.PoshDevOps"

    $confirmationPromptQuery = "Are you sure you want to delete the task group located at $TaskGroupDirPath`?"
    $confirmationPromptCaption = 'Confirm task group removal'

    if($Force.IsPresent -or $PSCmdlet.ShouldContinue($confirmationPromptQuery,$confirmationPromptCaption)){
        Remove-Item -Path $taskGroupDirPath -Recurse -Force
    }
}

function Invoke-PoshDevOpsTaskGroup(

[Hashtable]
[Parameter(
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true)]
$Parameters,

[string[]]
[Parameter(
    ValueFromPipelineByPropertyName=$true)]
$PackageSources = $defaultPackageSources,

[String]
[Parameter(
    ValueFromPipelineByPropertyName=$true)]
$ProjectRootDirPath='.'){
    
    $taskGroupDirPath = Resolve-Path "$ProjectRootDirPath\.PoshDevOps"
    $taskGroupFilePath = "$taskGroupDirPath\TaskGroup.psd1"
    $packagesDirPath = "$taskGroupDirPath\Packages"

    if(Test-Path $taskGroupFilePath){

        EnsureNuGetInstalled

        $TaskGroup = Get-PoshDevOpsTaskGroup -ProjectRootDirPath $ProjectRootDirPath

        foreach($task in $TaskGroup.Tasks.Values){
                    
            if($Parameters.($task.Name)){

                if($task.Parameters){

Write-Debug "Adding union of passed parameters and archived parameters to pipeline. Passed parameters will override archived parameters"
                
                    $taskParameters = Get-UnionOfHashtables -Source1 $Parameters.($task.Name) -Source2 $task.Parameters

                }
                else{

Write-Debug "Adding passed parameters to pipeline"

                    $taskParameters = $Parameters.($task.Name)
            
                }

            }
            elseif($task.Parameters){

Write-Debug "Adding archived parameters to pipeline"    
                $taskParameters = $task.Parameters

            }
            else{
                
                $taskParameters = @{}
            
            }

Write-Debug "Adding automatic parameters to pipeline"
            
            $taskParameters.PoshDevOpsProjectRootDirPath = (Resolve-Path $ProjectRootDirPath)
            $taskParameters.PoshDevOpsTaskName = $task.Name

Write-Debug "Ensuring task module package installed"
            nuget install $task.PackageId -Version $task.PackageVersion -OutputDirectory $packagesDirPath -Source $PackageSources -NonInteractive

            $moduleDirPath = "$packagesDirPath\$($task.PackageId).$($task.PackageVersion)\tools\$($task.PackageId)"
Write-Debug "Importing module located at: $moduleDirPath"
            Import-Module $moduleDirPath -Force

Write-Debug `
@"
Invoking task $($task.Name) with parameters: 
$($taskParameters|Out-String)
"@
            # Parameters must be PSCustomObject so [Parameter(ValueFromPipelineByPropertyName = $true)] works
            [PSCustomObject]$taskParameters.Clone() | Invoke-PoshDevOpsTask

        }
    }
    else{

throw "TaskGroup.psd1 not found at: $taskGroupFilePath"

    }
}

Export-ModuleMember -Function Invoke-PoshDevOpsTaskGroup,New-PoshDevOpsTaskGroup,Remove-PoshDevOpsTaskGroup,Add-PoshDevOpsTask,Set-PoshDevOpsTaskParameters,Remove-PoshDevOpsTask,Get-PoshDevOpsTaskGroup
tools\Src\PsonConverters.ps1
Set-Alias ConvertFrom-Pson Invoke-Expression -Description "Convert variable from PSON"


Function ConvertTo-Pson(
[Parameter(
    ValueFromPipeline=$true)]
$InputObject, 
[Int]
$Depth = 9, 
[Int]
$Layers = 1,
[Switch]
$Strict) {
<#
    .LINK http://stackoverflow.com/questions/15139552/save-hash-table-in-powershell-object-notation-pson
#>

    $Format = $Null
    $Quote = If ($Depth -le 0) {""} Else {""""}
    $Space = If ($Layers -le 0) {""} Else {" "}

    If ($InputObject -eq $Null) {"`$Null"} Else {
        
        $Type = "[" + $InputObject.GetType().Name + "]"

        $PSON = If ($InputObject -is [Array]) {
            
            $Format = "@(", ",$Space", ")"
            
            If ($Depth -gt 1) {

                For ($i = 0; $i -lt $InputObject.Count; $i++) {

                    ConvertTo-PSON $InputObject[$i] ($Depth - 1) ($Layers - 1) -Strict:$Strict

                }
            
            }

        } ElseIf ($InputObject -is [Xml]) {

            $Type = "[Xml]"
            $String = New-Object System.IO.StringWriter
            $InputObject.Save($String)
            $Xml = "'" + ([String]$String).Replace("`'", "&apos;") + "'"
            If ($Layers -le 0) {
            
                ($Xml -Replace "\r\n\s*", "") -Replace "\s+", " "

            } ElseIf ($Layers -eq 1) {

                $Xml
            
            } Else {
            
                $Xml.Replace("`r`n", "`r`n`t")
            
            }

            $String.Dispose()

        } ElseIf ($InputObject -is [DateTime]) {

            "$Quote$($InputObject.ToString('s'))$Quote"
        
        } ElseIf ($InputObject -is [String]) {

            0..11 | ForEach {$InputObject = $InputObject.Replace([String]"```'""`0`a`b`f`n`r`t`v`$"[$_], ('`' + '`''"0abfnrtv$'[$_]))}; "$Quote$InputObject$Quote"
        
        } ElseIf ($InputObject -is [Boolean]) {

            "`$$InputObject"
        
        } ElseIf ($InputObject -is [Char]) {
            
            If ($Strict) {[Int]$InputObject} Else {"$Quote$InputObject$Quote"}

        } ElseIf ($InputObject -is [ValueType]) {

            $InputObject

        } ElseIf ($InputObject -as [Hashtable]){

            if($InputObject -is [System.Collections.Specialized.OrderedDictionary]){              
                $Type = "[Ordered]"  
            }
            
            $Format = "@{", ";$Space", "}"
            
            If ($Depth -gt 1){

                $InputObject.GetEnumerator() | ForEach {$_.Name + "$Space=$Space" + (ConvertTo-PSON $_.Value ($Depth - 1) ($Layers - 1) -Strict:$Strict)}
            
            }
        } ElseIf ($InputObject -is [Object]) {

            $Format = "@{", ";$Space", "}"

            If ($Depth -gt 1) {

                $InputObject.PSObject.Properties | ForEach {$_.Name + "$Space=$Space" + (ConvertTo-PSON $_.Value ($Depth - 1) ($Layers - 1) -Strict:$Strict)}
            
            }
        
        } Else {

            $InputObject
        
        }

        If ($Format) {

            $PSON = $Format[0] + (&{

                If (($Layers -le 1) -or ($PSON.Count -le 0)) {

                    $PSON -Join $Format[1]
                
                } Else {
                
                    ("`r`n" + ($PSON -Join "$($Format[1])`r`n")).Replace("`r`n", "`r`n`t") + "`r`n"
                
                }
            
            }) + $Format[2]
        
        }

        If ($Strict) {
            "$Type$PSON"
        } Else {
            "$PSON"
        }
    }
}



tools\Src\Templates\TaskGroup.psd1
 
tools\Src\Uninstall.ps1
# remove source
$installRootDirPath = "C:\Program Files\PoshDevOps"
$installDirPath = "$installRootDirPath\Modules"

# make idempotent
if(Test-Path "$installRootDirPath"){
    Remove-Item $installRootDirPath -Force -Recurse
}

# remove $PSModulePath modification
$psModulePath = [Environment]::GetEnvironmentVariable('PSModulePath','Machine')

$newPSModulePathParts = @();
$isPSModulePathModified = $false
foreach($part in $psModulePath.Split(';')){
    if($part -eq $installDirPath){
        $isPSModulePathModified = $true
    }
    else{
        $newPSModulePathParts += $part;        
    }
}

$psModulePath = $newPSModulePathParts -join ';'

if($isPSModulePathModified){
    Write-Debug "updating '$env:PSModulePath' to $psModulePath"

    # save
    [Environment]::SetEnvironmentVariable('PSModulePath',$psModulePath,'Machine')
}

Log in or click on link to see number of positives.

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Version Downloads Last Updated Status
PoshDevOps 0.0.71 305 Friday, March 27, 2015 Approved
PoshDevOps 0.0.69 318 Friday, March 27, 2015 Approved
PoshDevOps 0.0.68 325 Thursday, March 26, 2015 Approved
PoshDevOps 0.0.64 343 Thursday, March 26, 2015 Approved
PoshDevOps 0.0.63 303 Wednesday, March 25, 2015 Approved
PoshDevOps 0.0.62 288 Wednesday, March 25, 2015 Approved
PoshDevOps 0.0.42 347 Wednesday, March 25, 2015 Approved
PoshDevOps 0.0.41 314 Tuesday, March 24, 2015 Approved

This package has no dependencies.

Discussion for the PoshDevOps Package

Ground Rules:

  • This discussion is only about PoshDevOps and the PoshDevOps package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or PoshDevOps, or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus