Skip to content

epetutsc/atlassian-cli

Repository files navigation

Atlassian CLI

A .NET tool that provides a command-line interface to interact with self-hosted Confluence, Jira, Bamboo, and BitBucket (on-prem) instances via their REST APIs.

Installation

Global Tool Installation

Install the tool globally using the .NET CLI:

dotnet tool install --global AtlassianCli

After installation, you can use the atlassiancli command from anywhere:

atlassiancli --help

Update

To update to the latest version:

dotnet tool update --global AtlassianCli

Uninstall

To uninstall the tool:

dotnet tool uninstall --global AtlassianCli

Features

Confluence

  • Create pages in any Confluence space
  • Read pages by ID or by title + space key
  • Update pages with replace or append mode
  • Support for Confluence storage format (XHTML)

Jira

  • Read issues by key
  • Create issues in any project
  • Add comments to issues
  • Change status of issues (transitions)
  • Assign users to issues
  • Update issue descriptions

Bamboo

  • List projects and view project details
  • List plans and view plan configuration
  • List branches for a plan
  • View build results for plans
  • Get build details including stages, changes, and test results
  • Get build logs with optional text filtering (e.g., filter for 'error' or 'exception')
  • Trigger builds (queue builds for plans and branches)

BitBucket

  • Get pull request information including title, description, state, and reviewers
  • View pull request diffs with file changes
  • List pull request commits with author and message details
  • Read pull request comments and review discussions
  • Add review comments to pull requests

General

  • Environment variable-based configuration
  • Comprehensive help system
  • Hierarchical sub-commands (confluence/jira/bamboo/bitbucket)

Requirements

  • .NET 10.0 SDK or later
  • Access to a Confluence, Jira, Bamboo, and/or BitBucket instance with REST API enabled

Configuration

Authentication Methods

The CLI supports three authentication methods (in order of preference):

  1. Bearer Token (Personal Access Token) - Recommended for on-premises instances

  2. API Token with Username - For Atlassian Cloud

    • Set both *_USERNAME and *_API_TOKEN
    • Uses HTTP Basic authentication with token as password
  3. Username and Password - Legacy method

    • Set both *_USERNAME and *_PASSWORD
    • Uses HTTP Basic authentication

Confluence Environment Variables

Variable Required Description
CONFLUENCE_BASE_URL Yes Base URL of your Confluence instance (e.g., https://confluence.example.com)
CONFLUENCE_API_TOKEN Conditional Personal Access Token for Bearer auth (use alone), or API token (use with username)
CONFLUENCE_USERNAME Conditional Username for Basic auth (required with API token for Cloud, or with password)
CONFLUENCE_PASSWORD Conditional Password for Basic auth (use with username)

Jira Environment Variables

Variable Required Description
JIRA_BASE_URL Yes Base URL of your Jira instance (e.g., https://jira.example.com)
JIRA_API_TOKEN Conditional Personal Access Token for Bearer auth (use alone), or API token (use with username)
JIRA_USERNAME Conditional Username for Basic auth (required with API token for Cloud, or with password)
JIRA_PASSWORD Conditional Password for Basic auth (use with username)

Bamboo Environment Variables

Variable Required Description
BAMBOO_BASE_URL Yes Base URL of your Bamboo instance (e.g., https://bamboo.example.com)
BAMBOO_API_TOKEN Conditional Personal Access Token for Bearer auth (use alone), or API token (use with username)
BAMBOO_USERNAME Conditional Username for Basic auth (required with API token for Cloud, or with password)
BAMBOO_PASSWORD Conditional Password for Basic auth (use with username)

BitBucket Environment Variables

Variable Required Description
BITBUCKET_BASE_URL Yes Base URL of your BitBucket instance (e.g., https://bitbucket.example.com)
BITBUCKET_API_TOKEN Conditional Personal Access Token for Bearer auth (use alone), or API token (use with username)
BITBUCKET_USERNAME Conditional Username for Basic auth (required with API token for Cloud, or with password)
BITBUCKET_PASSWORD Conditional Password for Basic auth (use with username)

Example Configurations

Bearer Token (Personal Access Token) - On-Premises

# Confluence with PAT
export CONFLUENCE_BASE_URL=https://confluence.example.com
export CONFLUENCE_API_TOKEN=your-personal-access-token

# Jira with PAT
export JIRA_BASE_URL=https://jira.example.com
export JIRA_API_TOKEN=your-personal-access-token

API Token with Username - Atlassian Cloud

# Confluence Cloud
export CONFLUENCE_BASE_URL=https://your-domain.atlassian.net/wiki
export CONFLUENCE_USERNAME=your.email@example.com
export CONFLUENCE_API_TOKEN=your-api-token

# Jira Cloud
export JIRA_BASE_URL=https://your-domain.atlassian.net
export JIRA_USERNAME=your.email@example.com
export JIRA_API_TOKEN=your-api-token

# Bamboo with PAT
export BAMBOO_BASE_URL=https://bamboo.example.com
export BAMBOO_API_TOKEN=your-personal-access-token

# BitBucket with PAT
export BITBUCKET_BASE_URL=https://bitbucket.example.com
export BITBUCKET_API_TOKEN=your-personal-access-token

Building

dotnet build

Usage

The CLI uses a hierarchical command structure where you first specify the service (confluence, jira, bamboo, or bitbucket) followed by the specific command.

Show Help

dotnet run -- --help
dotnet run -- confluence --help
dotnet run -- jira --help
dotnet run -- bamboo --help
dotnet run -- bitbucket --help

File Support

All commands that accept body or description content support reading from a UTF-8 encoded file using the --file option (or --description-file for create-issue). This allows you to provide content from a file instead of the command line.

Example with file:

dotnet run -- confluence create-page --space MYSPACE --title "My Page" --file content.html

Confluence Commands

Create a Page

dotnet run -- confluence create-page --space MYSPACE --title "My New Page" --body "<p>Hello Confluence!</p>"

With file:

dotnet run -- confluence create-page --space MYSPACE --title "My New Page" --file content.html

Options:

  • -s, --space (required): Space key
  • -t, --title (required): Page title
  • -b, --body: Page content in storage format (either --body or --file is required)
  • --file: Path to a UTF-8 encoded file containing the body content

Get a Page

By ID:

dotnet run -- confluence get-page --id 12345

By title and space:

dotnet run -- confluence get-page --space MYSPACE --title "My Page"

Options:

  • -i, --id: Page ID
  • -s, --space: Space key (required with --title)
  • -t, --title: Page title (required with --space)
  • -f, --format: Output format - storage (default) or view

Update a Page

Replace content:

dotnet run -- confluence update-page --id 12345 --body "<p>New content</p>"

Append content:

dotnet run -- confluence update-page --id 12345 --body "<p>Additional content</p>" --append

Update by title:

dotnet run -- confluence update-page --space MYSPACE --title "My Page" --body "<p>Updated</p>"

With file:

dotnet run -- confluence update-page --id 12345 --file content.html
dotnet run -- confluence update-page --id 12345 --file content.html --append

Options:

  • -i, --id: Page ID
  • -s, --space: Space key (required with --title)
  • -t, --title: Page title (required with --space)
  • -b, --body: New page content (either --body or --file is required)
  • --file: Path to a UTF-8 encoded file containing the body content
  • -a, --append: Append to existing content instead of replacing

Jira Commands

Get an Issue

dotnet run -- jira get-issue --key PROJ-123

Options:

  • -k, --key (required): Issue key (e.g., PROJ-123)

Create an Issue

dotnet run -- jira create-issue --project PROJ --summary "My new task" --type Task

With description:

dotnet run -- jira create-issue --project PROJ --summary "Bug fix needed" --type Bug --description "Detailed description here"

With description from file:

dotnet run -- jira create-issue --project PROJ --summary "Task" --type Task --description-file desc.txt

Options:

  • -p, --project (required): Project key
  • -s, --summary (required): Issue summary/title
  • -t, --type (required): Issue type (e.g., Task, Bug, Story)
  • -d, --description: Issue description
  • --description-file: Path to a UTF-8 encoded file containing the description

Add a Comment

dotnet run -- jira add-comment --key PROJ-123 --body "This is my comment"

With file:

dotnet run -- jira add-comment --key PROJ-123 --file comment.txt

Options:

  • -k, --key (required): Issue key
  • -b, --body: Comment body text (either --body or --file is required)
  • --file: Path to a UTF-8 encoded file containing the comment body

Change Status

dotnet run -- jira change-status --key PROJ-123 --status "In Progress"

Options:

  • -k, --key (required): Issue key
  • -s, --status (required): Target status name (e.g., "In Progress", "Done")

Note: The status must be a valid transition from the current issue status.

Assign User

dotnet run -- jira assign-user --key PROJ-123 --user john.doe

Options:

  • -k, --key (required): Issue key
  • -u, --user (required): Username or display name to assign

Update Issue Description

dotnet run -- jira update-issue --key PROJ-123 --description "Updated description for the issue"

With file:

dotnet run -- jira update-issue --key PROJ-123 --file description.txt

Options:

  • -k, --key (required): Issue key
  • -d, --description: New description (either --description or --file is required)
  • --file: Path to a UTF-8 encoded file containing the description

Bamboo Commands

List Projects

dotnet run -- bamboo get-projects

Get a Project

dotnet run -- bamboo get-project --key PROJ

Options:

  • -k, --key (required): Project key (e.g., PROJ)

List Plans

dotnet run -- bamboo get-plans

Filter by project:

dotnet run -- bamboo get-plans --project PROJ

Options:

  • -p, --project: Filter plans by project key (optional)

Get a Plan (with configuration)

dotnet run -- bamboo get-plan --key PROJ-PLAN

Options:

  • -k, --key (required): Plan key (e.g., PROJ-PLAN)

This shows plan details including stages, variables, and branches.

List Plan Branches

dotnet run -- bamboo get-branches --key PROJ-PLAN

Options:

  • -k, --key (required): Plan key

List Build Results

dotnet run -- bamboo get-builds --key PROJ-PLAN

With limited results:

dotnet run -- bamboo get-builds --key PROJ-PLAN --max-results 10

Options:

  • -k, --key (required): Plan key
  • -n, --max-results: Maximum number of results (default: 25)

Get a Specific Build Result

dotnet run -- bamboo get-build --key PROJ-PLAN-123

Options:

  • -k, --key (required): Build result key (e.g., PROJ-PLAN-123)

This shows detailed build information including stages, changes, and test results.

Get Latest Build Result

dotnet run -- bamboo get-latest-build --key PROJ-PLAN

Options:

  • -k, --key (required): Plan key

Queue a Build (Trigger Build)

Queue a build for the default branch:

dotnet run -- bamboo queue-build --key PROJ-PLAN

Queue a build for a specific branch:

dotnet run -- bamboo queue-build --key PROJ-PLAN --branch feature/my-branch

Options:

  • -k, --key (required): Plan key
  • -b, --branch: Branch name (optional, builds default branch if not specified)

Get Build Logs

Get the logs from a build:

dotnet run -- bamboo get-build-logs --key PROJ-PLAN-123

Filter logs using regex pattern:

dotnet run -- bamboo get-build-logs --key PROJ-PLAN-123 -f error

Use multiple filters (lines matching ANY pattern are shown):

dotnet run -- bamboo get-build-logs --key PROJ-PLAN-123 -f error -f exception

Use regex OR pattern:

dotnet run -- bamboo get-build-logs --key PROJ-PLAN-123 -f 'error|exception'

Use regex to find complex patterns:

dotnet run -- bamboo get-build-logs --key PROJ-PLAN-123 -f 'failed.*test'

Get logs for a specific job within the build:

dotnet run -- bamboo get-build-logs --key PROJ-PLAN-123 --job PROJ-PLAN-JOB1

Options:

  • -k, --key (required): Build result key (e.g., PROJ-PLAN-123)
  • -f, --filter: Filter log lines using regex patterns (case-insensitive). Can be specified multiple times.
  • -j, --job: Get logs for a specific job within the build

BitBucket Commands

Get Pull Request

Get detailed information about a pull request:

dotnet run -- bitbucket get-pr --project PROJ --repo my-repo --id 123

Short form:

dotnet run -- bitbucket get-pr -p PROJ -r my-repo -i 123

Options:

  • -p, --project (required): Project key (e.g., PROJ)
  • -r, --repo (required): Repository slug (e.g., my-repo)
  • -i, --id (required): Pull request ID

Get Pull Request Diff

Get the diff for a pull request showing all file changes:

dotnet run -- bitbucket get-pr-diff --project PROJ --repo my-repo --id 123

Options:

  • -p, --project (required): Project key
  • -r, --repo (required): Repository slug
  • -i, --id (required): Pull request ID

Get Pull Request Commits

List all commits in a pull request:

dotnet run -- bitbucket get-pr-commits --project PROJ --repo my-repo --id 123

Options:

  • -p, --project (required): Project key
  • -r, --repo (required): Repository slug
  • -i, --id (required): Pull request ID

Get Pull Request Comments

List all comments and review discussions on a pull request:

dotnet run -- bitbucket get-pr-comments --project PROJ --repo my-repo --id 123

Options:

  • -p, --project (required): Project key
  • -r, --repo (required): Repository slug
  • -i, --id (required): Pull request ID

Add Pull Request Comment

Add a review comment to a pull request:

dotnet run -- bitbucket add-pr-comment --project PROJ --repo my-repo --id 123 --text "This looks good!"

With file:

dotnet run -- bitbucket add-pr-comment --project PROJ --repo my-repo --id 123 --file review-comment.txt

Short form:

dotnet run -- bitbucket add-pr-comment -p PROJ -r my-repo -i 123 -t "LGTM"

Options:

  • -p, --project (required): Project key
  • -r, --repo (required): Repository slug
  • -i, --id (required): Pull request ID
  • -t, --text: Comment text (either --text or --file is required)
  • --file: Path to a UTF-8 encoded file containing the comment text

Project Structure

AtlassianCli/
├── Program.cs                    # Entry point, CLI parsing
├── Client/
│   ├── ConfluenceClient.cs       # Confluence REST API client
│   ├── JiraClient.cs             # Jira REST API client
│   ├── BambooClient.cs           # Bamboo REST API client
│   └── BitBucketClient.cs        # BitBucket REST API client
├── Models/
│   ├── ConfluenceModels.cs       # Confluence data transfer objects
│   ├── JiraModels.cs             # Jira data transfer objects
│   ├── BambooModels.cs           # Bamboo data transfer objects
│   └── BitBucket*.cs             # BitBucket data transfer objects
├── Commands/
│   ├── CommandOptions.cs         # CLI option definitions
│   └── CommandHandlers.cs        # Command execution logic
└── Progress.md                   # Development progress tracking

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages