Skip to content

Catesta - Bitbucket Pipelines Integration

Synopsis

Scaffolds a new PowerShell module or vault project intended for CI/CD workflow using Bitbucket.

Getting Started


Note: It's important to understand your project's requirements before choosing a CI/CD solution with Catesta. Bitbucket only natively supports Linux containers for builds, limiting your module to be built and tested on Linux using PowerShell. However, Bitbucket recently announced support for Windows runners, allowing you to run builds on your own Windows infrastructure. Although Catesta can't scaffold for this scenario, there's nothing preventing a user from setting up their own Windows runner for their Catesta scaffolded project.

Cross Platform


  1. You will need an Atlassian account.
  2. Create a new Project/Repository:
    • Bitbucket New Project
    • Note: To create a new repository in Bitbucket, you have two options: either create a new project and then a new repository within it, or create a new repository and associate it with a new project during the creation process.
  3. Create your project using Catesta and select [B] Bitbucket at the CICD prompt. (Catesta Basics)
  4. Write the logic for your module (the hardest part)
    • All build testing can be done locally by navigating to src and running Invoke-Build
      • By default, this runs all tasks in the build file.
        • If you want to run a specific task from the build file you can provide the task name. For example, to just execute Pester tests for your project: Invoke-Build -Task Test
    • If using VSCode as your primary editor you can use VSCode tasks to perform various local actions
      • Open the VSCode Command palette
        • Shift+Command+P (Mac) / Ctrl+Shift+P (Windows/Linux) or F1
      • Type Tasks: Run Task
      • Select the task to run
        • Examples:
          • task . - Runs complete build (all tasks)
          • task Test - Invokes all Pester Unit Tests
          • task Analyze - Invokes Script Analyzer checks
          • task DevCC - Generates generate xml file to graphically display code coverage in VSCode using Coverage Gutters
  5. Add any module dependencies to your CI/CD bootstrap file: actions_bootstrap.ps1
  6. Upload to your Bitbucket repository which now has a triggered/monitored build action.
  7. Evaluate results of your build.

Bitbucket Pipelines PowerShell project created by Catesta

Test Reports

Your Bitbucket Pipelines project is configured to generate test reports in JUnitXml format.

Passing Report

Bitbucket does not provide a detailed report when all tests are successful. You will only get an overview of the results report:

Bitbucket Pipelines PowerShell project all tests passing

Failed Report

When you project experiences a failed tests Bitbucket will add a Tests tab to your pipeline. Here you will be able to see a detailed breakdown of which test(s_ experienced an issue.

Bitbucket Pipelines PowerShell project failed Tests tab

Notes

Additional Reading:

Diagrams

AppVeyor Integration with GitHub

Catesta PowerShell Bitbucket Diagram