Coder Social home page Coder Social logo

ps-bitbucket's Introduction

Powershell BitBucket module

PS.BitBucket is a PowerShell module that provides cmdlets to intract with BitBucket instance. It uses most of the REST API reference availabe here REST API and few from other places like Branch permission.

This allows fast access to BitBucket UI functions in automated way.

The module handles only authenticated method, it supports multiple funcationlity of BitBucket in group manner (useful for Administrator to GET stats), Here are few example (Detailed below) supported: :Project, Repo, Branch, BranchPermission, Size, ListOfRepos, CreateRepo, CreateBranch, CurrentVersion

Getting Started

PS.BitBucket is available on PowerShell Gallery , You can install package if you have PowerShellGet installed already, otherwise you can follow the instruction to install from PowerShell Gallery here https://www.powershellgallery.com/.

Install module

Install-Module -Name PS.BitBucket

To start with

Set BitBucket server URL and login Credentails, This will be used for all the command you run. In most cases, to get full information, its good to have admininstrator level access.

Set server URL

Set-BitBucketServer -Url "http://example:7990"

Set Credential

Set-BitBucketCredential -Credential admin

Verify

Get-BitBucketServer
Get-BitBucketInfo

Note: All these command output depends on permission you have. Any information are shown by these cmdlets are similar to what you see on UI.

Get all projects

Get-BitBucketProjects

Get all Repositories under given Project ID

Get-BitBucketRepoByProject -Project "TES"

Get all repository hosted on Bitbucket

Get-BitBucketAllRepo

Create a new empty repository

New-BitBucketRepo -Project "TES" -Repository "ABC"

(There are mutliple optional param available for New-BitBucketRepo, All of these works if pass with -WithGitFlowBranch)

Set the user full name and email (This required in order to get user real name when pushing new branches)

Set-UserFullNameAndEmail -FullName "admin" -EmailId "[email protected]"

Create a new repository with gitflow branch (develop/master)

New-BitBucketRepo -Project "TES" -Repository "ABC" -WithGitFlowBranch

Note: Above command also looks for a .gitignore file under C:\Git\ folder.

Create a new repository with gitflow branch and set develop as default branch (Git push marks master as default)

New-BitBucketRepo -Project "TES" -Repository "ABC" -WithGitFlowBranch -SetDefaultBranch

You can also change default branch at later stage as

Set-DefaultBranch -Project "TES" -Repository "ABC" -Branch "develop"

Create a new repository with gitflow branch, Set branch permission as attached Screenshot

New-BitBucketRepo -Project "TES" -Repository "ABC" -WithGitFlowBranch -SetBranchPermission

Note: I have added a standard branch permission, every org has different set of branch permission, to use your own org standard branch permission, write a file similar to public\BranchPermission.json. There are two ways to set custom branch permission

  1. Do while creating a new repo
New-BitBucketRepo -Project "TES" -Repository "ABC" -WithGitFlowBranch -SetBranchPermission -BranchPermissionJson "C:\BranchPer.json"
  1. Change at later stage for existing repo
Set-BranchPermission -Project "TES" -Repository "ABC" --BranchPermissionJson "C:\BranchPer.json"

OR to set branch permission as defined in this module for existing repo:

Set-BranchPermission -Project "TES" -Repository "ABC"

Below cmdlet will help to get size for repositories under given projects or all the repository hosted on BitBucket. These are requred sometime for audit purpose. (Limitation: These command will break if a repository name has space, I am still working on it)

Get all repository Approximate size (in KBs) for given Projects

Get-BitBucketRepoSizeByProject -Project "TES"

Get all repository Approximate size (in KBs)

Get-BitBucketAllRepoSize

Create new branch

New-CreateBranch -Project "TES" -Repository "TEST1" -SourceBranch "refs/heads/develop" -NewBranch "release/1.0"

Disclaimer/Issues

This is an open source project which is NOT supported by the BitBucket team. All questions/bugs about this module should be entered on this github project or feel free to contribute to this project if you have a possible fix for it. Feel free to request for new feature/cmdlet. Your suggestion/request will help shape up the module according to needs of the community. All these current implementation are based on my experience with BitBucket day to day usage.

Authors

Created and maintained by Shankar.

License

Apache License, Version 2.0 (see LICENSE)

ps-bitbucket's People

Contributors

i9shankar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ps-bitbucket's Issues

Update PowerShellGallery version

Hello,

The version on PowerShellGallery does not correspond to the latest version on master. Could we perhaps get a new version on PowerShellGallery?

Changes from #1 is missing on PSGallery

Not all functions are exported

Please check https://www.powershellgallery.com/packages/PS.BitBucket/1.1.3/Content/PS.BitBucket.psd1

Not all the new functions are exported. As a result, they won't be found on command shell.

The term 'Set-UserFullNameAndEmail' is not recognized as the name of a cmdlet, function, script file, or operable program.

I have imported this Ps-bitbucket module and then I am trying to run Set-UserFullNameAndEmail command it is giving me an error like this.

The term 'Set-UserFullNameAndEmail' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.

When I ran Get-Help Set-UserFullNameAndEmail to investigate more into this.

get-help : Get-Help could not find Set-UserFullNameAndEmail in a help file in this session. To download updated help
topics type: "Update-Help".

When I ran update-help

update-help : Failed to update Help for the module(s) 'HostNetworkingService, PS.BitBucket, WindowsUpdateProvider'
with UI culture(s) {en-US} : Unable to retrieve the HelpInfo XML file for UI culture en-US. Make sure the HelpInfoUri
property in the module manifest is valid or check your network connection and then try the command again.

in Get -module it is showing the latest version i.e. 1.1.3 . I am not getting where the issue is.. Please help me.

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.