Unpacking Software Livestream

Join our monthly Unpacking Software livestream to hear about the latest news, chat and opinion on packaging, software deployment and lifecycle management!

Learn More

Chocolatey Product Spotlight

Join the Chocolatey Team on our regular monthly stream where we put a spotlight on the most recent Chocolatey product releases. You'll have a chance to have your questions answered in a live Ask Me Anything format.

Learn More

Chocolatey Coding Livestream

Join us for the Chocolatey Coding Livestream, where members of our team dive into the heart of open source development by coding live on various Chocolatey projects. Tune in to witness real-time coding, ask questions, and gain insights into the world of package management. Don't miss this opportunity to engage with our team and contribute to the future of Chocolatey!

Learn More

Calling All Chocolatiers! Whipping Up Windows Automation with Chocolatey Central Management

Webinar from
Wednesday, 17 January 2024

We are delighted to announce the release of Chocolatey Central Management v0.12.0, featuring seamless Deployment Plan creation, time-saving duplications, insightful Group Details, an upgraded Dashboard, bug fixes, user interface polishing, and refined documentation. As an added bonus we'll have members of our Solutions Engineering team on-hand to dive into some interesting ways you can leverage the new features available!

Watch On-Demand
Chocolatey Community Coffee Break

Join the Chocolatey Team as we discuss all things Community, what we do, how you can get involved and answer your Chocolatey questions.

Watch The Replays
Chocolatey and Intune Overview

Webinar Replay from
Wednesday, 30 March 2022

At Chocolatey Software we strive for simple, and teaching others. Let us teach you just how simple it could be to keep your 3rd party applications updated across your devices, all with Intune!

Watch On-Demand
Chocolatey For Business. In Azure. In One Click.

Livestream from
Thursday, 9 June 2022

Join James and Josh to show you how you can get the Chocolatey For Business recommended infrastructure and workflow, created, in Azure, in around 20 minutes.

Watch On-Demand
The Future of Chocolatey CLI

Livestream from
Thursday, 04 August 2022

Join Paul and Gary to hear more about the plans for the Chocolatey CLI in the not so distant future. We'll talk about some cool new features, long term asks from Customers and Community and how you can get involved!

Watch On-Demand
Hacktoberfest Tuesdays 2022

Livestreams from
October 2022

For Hacktoberfest, Chocolatey ran a livestream every Tuesday! Re-watch Cory, James, Gary, and Rain as they share knowledge on how to contribute to open-source projects such as Chocolatey CLI.

Watch On-Demand

Downloads:

2,684

Downloads of v 0.0.76:

299

Last Update:

04 Feb 2015

Package Maintainer(s):

Software Author(s):

  • Chris Dostert

Tags:

powershell posh-ci taskrunner ci continuousintegration build deployment admin

Posh-CI

  • 1
  • 2
  • 3

0.0.76 | Updated: 04 Feb 2015

Downloads:

2,684

Downloads of v 0.0.76:

299

Maintainer(s):

Software Author(s):

  • Chris Dostert

Posh-CI 0.0.76

  • 1
  • 2
  • 3

All Checks are Unknown

2 Tests in Unknown Status


Validation Testing Unknown


Verification Testing Unknown


Scan Testing Unknown

Package Approved

This package was approved as a trusted package on 15 Feb 2015.

WARNING

This package is unlisted and hidden from package listings.

Description

Posh-CI: The Powershell Task Runner

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


tools\tools\chocolateyInstall.ps1
try {    
    
    . "$PSScriptRoot\Posh-CI\Install.ps1"

    Write-ChocolateySuccess 'Posh-CI'

} catch {

    Write-ChocolateyFailure 'Posh-CI' $_.Exception.Message

    throw 
}
tools\tools\chocolateyUninstall.ps1
try {

    . "$PSScriptRoot\Posh-CI\Uninstall.ps1"

    Write-ChocolateySuccess 'Posh-CI'

} catch {

    Write-ChocolateyFailure 'Posh-CI' $_.Exception.Message

    throw 
}
tools\tools\Posh-CI\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 "Posh-CI requires PowerShell 3.0 or better; you have version $($Host.Version)."
    return
}

# prepare install dir
$installRootDirPath = "$env:ProgramFiles\Posh-CI"
$installDirPath = "$installRootDirPath\Modules"

# handle upgrade scenario
if(Test-Path "$installRootDirPath"){
    Write-Debug 'removing previous Posh-CI 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 Posh-CI installation
    $psModulePath = $psModulePath + ";$installDirPath"
    
    # save
    [Environment]::SetEnvironmentVariable('PSModulePath',$psModulePath,'Machine')    
    
    # make effective in current session
    $env:PSModulePath = $env:PSModulePath + ";$installDirPath"
}
tools\tools\Posh-CI\Posh-CI.psd1
 
tools\tools\Posh-CI\Posh-CI.psm1
function EnsureChocolateyInstalled(){

    # install chocolatey
    try{
        Get-Command choco -ErrorAction 'Stop' | Out-Null
    }
    catch{             
        iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
    }

}

function Get-CIPlanDirPath(
[string][Parameter(Mandatory=$true)]$ProjectRootDirPath){

    "$ProjectRootDirPath\CIPlan"

}

function Get-CIStepsDirPath(
[string][Parameter(Mandatory=$true)]$ProjectRootDirPath){    

    "$(Get-CIPlanDirPath $ProjectRootDirPath)\Steps"

}

function ConvertTo-CIPlanArchiveJson(
[PSCustomObject][Parameter(Mandatory=$true)]$CIPlan){
    <#
        .SUMMARY
        an internal utility function to convert a runtime CIPlan object to a 
        ci plan archive formatted as a json string
    #>

    # construct ci plan archive from ci plan
    $ciPlanArchiveSteps = @()
    $CIPlan.Steps.Values | %{$ciPlanArchiveSteps += $_}
    $ciPlanArchive = [PSCustomObject]@{'Steps'=$ciPlanArchiveSteps}

    return ConvertTo-Json -InputObject $ciPlanArchive -Depth 6

}

function ConvertFrom-CIPlanArchiveJson(
[string]$CIPlanFileContent){
    <#
        .SUMMARY
        an internal utility function to convert a ci plan archive formatted as a json string
        into a runtime CIPlan object.
    #>

    $ciPlanArchive = $CIPlanFileContent -join "`n" | ConvertFrom-Json

    # construct a ci plan from a ci plan archive
    $ciPlanSteps = [ordered]@{}
    $ciPlanArchive.Steps | %{$ciPlanSteps.Add($_.Name,$_)}
    
    return [pscustomobject]@{'Steps'=$ciPlanSteps}

}

function Get-CIPlan(
[string][Parameter(Mandatory=$true)]$ProjectRootDirPath){
    <#
        .SUMMARY
        an internal utility function to retrieve a CIPlan file and 
        instantiate a runtime CIPlan object.
    #>

    $ciPlanDirPath = "$ProjectRootDirPath\CIPlan"
    $ciPlanFilePath = "$ciPlanDirPath\CIPlanArchive.json"
    return ConvertFrom-CIPlanArchiveJson -CIPlanFileContent (Get-Content $ciPlanFilePath)

}

function Save-CIPlan(
[psobject]$CIPlan,
[string][Parameter(Mandatory=$true)]$ProjectRootDirPath){
    <#
        .SUMMARY
        an internal utility function to save a runtime CIPlan object as 
        a CIPlan file.
    #>
    
    $ciPlanDirPath = "$ProjectRootDirPath\CIPlan"
    $ciPlanFilePath = "$ciPlanDirPath\CIPlanArchive.json"    
    Set-Content $ciPlanFilePath -Value (ConvertTo-CIPlanArchiveJson -CIPlan $CIPlan)
}

function Add-CIStep(
[string][Parameter(Mandatory=$true)]$Name,
[string][Parameter(Mandatory=$true)]$ModulePath,
[string]$ProjectRootDirPath = $PWD){

    $ciPlan = Get-CIPlan -ProjectRootDirPath $ProjectRootDirPath
    
    if($ciPlan.Steps.Contains($Name)){

        throw "A ci step with name $Name already exists.`n Tip: You can remove the existing step by invoking Remove-CIStep"
            
    }
    else{
        
        # add step to plan
        $ciPlan.Steps.Add($Name, [PSCustomObject]@{'Name'=$Name;'ModulePath'=$ModulePath})
        Save-CIPlan -CIPlan $ciPlan -ProjectRootDirPath $ProjectRootDirPath    

    }
}

function Remove-CIStep(
[string][Parameter(Mandatory=$true)]$Name,
[switch]$Force,
[string]$ProjectRootDirPath = $PWD){

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

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

        # remove step from plan
        $ciPlan = Get-CIPlan -ProjectRootDirPath $ProjectRootDirPath
        $ciPlan.Steps.Remove($Name)
        Save-CIPlan -CIPlan $ciPlan -ProjectRootDirPath $ProjectRootDirPath
    }

}

function New-CIPlan(
[string]$ProjectRootDirPath= $PWD){
    $ciPlanDirPath = Get-CIPlanDirPath $ProjectRootDirPath  

    if(!(Test-Path $ciPlanDirPath)){    
        $templatesDirPath = "$PSScriptRoot\Templates"
        $CIStepsDirPath = Get-CIStepsDirPath $ProjectRootDirPath

        # create a directory for the plan
        New-Item -ItemType Directory -Path $ciPlanDirPath

        # create a directory for the plans Steps
        New-Item -ItemType Directory -Path $CIStepsDirPath  

        # create default files
        Copy-Item -Path "$templatesDirPath\CIPlanArchive.json" $ciPlanDirPath
        Copy-Item -Path "$templatesDirPath\Packages.config" $ciPlanDirPath
    }
    else{        
        throw "CIPlan directory already exists at $ciPlanDirPath. If you are trying to recreate your ci plan from scratch you must invoke Remove-CIPlan first"
    }
}

function Remove-CIPlan(
[switch]$Force,
[string]$ProjectRootDirPath= $PWD){
    
    $ciPlanDirPath = Get-CIPlanDirPath $ProjectRootDirPath

    $confirmationPromptQuery = "Are you sure you want to delete the CI plan located at $CIPlanDirPath`?"
    $confirmationPromptCaption = 'Confirm ci plan removal'

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

function Invoke-CIPlan(

[PSCustomObject]
[Parameter(
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true)]
$Variables=@{'PoshCIHello'="Hello from Posh-CI!"},

[String]
$ProjectRootDirPath='.'){
    
    $ciPlanDirPath = Resolve-Path "$ProjectRootDirPath\CIPlan"
    $ciPlanFilePath = "$ciPlanDirPath\CIPlanArchive.json"
    $packagesFilePath = "$ciPlanDirPath\Packages.config"
    if(Test-Path $ciPlanFilePath){
        EnsureChocolateyInstalled
        choco install $packagesFilePath

        # add variables to session
        $CIPlan = Get-CIPlan -ProjectRootDirPath $ProjectRootDirPath

        foreach($step in $CIPlan.Steps.Values){
            Import-Module (resolve-path $step.ModulePath) -Force
            $Variables | Invoke-CIStep
        }
    }
    else{
        throw "CIPlanArchive.json not found at: $ciPlanFilePath"
    }
}

Export-ModuleMember -Function Invoke-CIPlan,New-CIPlan,Remove-CIPlan,Add-CIStep,Remove-CIStep
tools\tools\Posh-CI\Templates\CIPlanArchive.json
{
	"Steps":[]
}
tools\tools\Posh-CI\Templates\CIStep.psm1
# halt immediately on any errors which occur in this module
$ErrorActionPreference = "Stop"

function Start-CIStep(
[String]$PoshCIHello){
    #define your ci step here!
    Write-Host $PoshCIHello
}

Export-ModuleMember Start-CIStep
tools\tools\Posh-CI\Templates\Packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
</packages>
tools\tools\Posh-CI\Uninstall.ps1
# remove source
$installRootDirPath = "C:\Program Files\Posh-CI"
$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')
}

No results available for this package. We are building up results for older packages over time so expect to see results. If this is a new package, it should have results within a day or two.

Add to Builder Version Downloads Last Updated Status

This package has no dependencies.

Discussion for the Posh-CI Package

Ground Rules:

  • This discussion is only about Posh-CI and the Posh-CI 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 Posh-CI, 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