Atlassian Stash PowerShell Module
PowerShell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Media
PSStash
Tests
.gitignore
LICENSE
README.md
appveyor.yml

README.md

Build status

Stash PowerShell Module

This is a PowerShell module for working with the Atlassian Stash REST API.

This is an quick and dirty implementation based on my environment's configuration, with limited functionality. Contributions to improve this would be more than welcome!

Chances are high that there will be breaking design changes, this is just a simple POC.

Examples:

Query for projects:

Public projects

Query for repositories:

Public projects

Query for project permissions:

Public projects

Public projects

Query for arbitrary objects:

Objects

Instructions:

# One time setup
    # Download the repository
    # Unblock the zip
    # Extract the PSStash folder to a module path (e.g. $env:USERPROFILE\Documents\WindowsPowerShell\Modules\)

# Import the module.
    Import-Module PSStash    #Alternatively, Import-Module \\Path\To\PSStash

# Get commands in the module
    Get-Command -Module PSStash

# Get help for a command
    Get-Help Get-StashObject -Full
    Get-Help Get-StashConfig -Full

# Set a default Uri
    Set-StashConfig -uri https://stash.contoso.com

# List public projects
    Get-StashProject

# List repositories that user in $cred has access to
    Get-StashObject -Object repos -Credential $cred

# List repositories under the 'sysinv' project
    Get-StashObject -Object projects/sysinv/repos -Credential $cred

# Create, change, and delete objects; for example, projects
    New-StashObject -Object projects -Credential $Cred -Body @{
        key = "TSTPRJ"
        name = "Test Project"
        description = "A Project To Delete"
        avatar = "data:image/png;base64,$Base64EncodedImage"
    }

    Set-StashObject -Object projects/TSTPRJ -Credential $cred -Body @{ description = "MODIFIED DESCRIPTION!" } -Force

    Remove-StashObject -Object projects/TSTPRJ -Credential $Cred -Force

# Fork a repository into my personal project:
    New-StashFork -Credential $cred -Project SYSINV -Repo SystemsInventory

# View repositories in my personal project:
    Get-StashObject -Object projects/~MYUSERNAME/repos -Credential $Cred

# Get project user and group permissions
    Get-StashProject | Get-StashProjectUserPermission -Cred $Cred
    Get-StashProject | Get-StashProjectGroupPermission -Cred $Cred

References:

TODO:

Everything. This is in the 'can I get it working' state. Need to identify requirements (e.g. which specific objects to create functions for, parameters for these objects, whether to pursue OAUTH) for further work, write functions, tests, etc.

Potential functions:

  • Get-StashProject
  • Get-StashRepo
  • New-StashFork
  • Get-StashProjectUserPermission
  • Get-StashProjectGroupPermission
  • New-StashProject
  • New-StashRepo
  • Remove-StashRepo
  • Get-StashProjectPermission
  • Set-StashProjectPermission
  • Add-StashProjectPermission
  • Get-StashRepoPermission
  • Set-StashRepoPermission
  • Add-StashRepoPermission
  • Remove-StashRepoPermission
  • Get-StashCommit
  • Merge-StashPullRequest
  • Add-StashPullRequestComment
  • Deny-StashPullRequest

Project Status, 1/17/2016: I no longer work with or have access to Stash / BitBucket Server. Feel free to fork this or use it as needed, but there will likely be no further development, barring external contributions.