DEV Community

Durrell  Gemuh
Durrell Gemuh

Posted on

Integrating Bitbucket with ArgoCD

Overview

This guide explains how to set up and connect Bitbucket repositories with ArgoCD for GitOps-powered continuous deployment in Kubernetes. ArgoCD monitors your Bitbucket Git repository for changes and ensures your Kubernetes cluster stays synchronized with the desired application state.

Prerequisites

  • Kubernetes cluster with ArgoCD installed and running
  • Bitbucket repository containing your application manifests or Helm charts
  • Access to Bitbucket account with rights to generate API tokens

Step 1: Create a Bitbucket Scoped API Token

  1. Log in to Bitbucket at bitbucket.org.
  2. Go to Personal SettingsAtlassian Account SettingsSecurity.
  3. Select Create and manage API tokens.
  4. Click Create API token.
  5. Enter a name (e.g., "ArgoCD access token").
  6. Select an expiration date if desired.
  7. Choose scopes:
    • repository:read
    • repository:write (if write operations needed)
    • account:read
  8. Click Create token.
  9. Copy the token immediately; you won't be able to retrieve it later.

Step 2: Add Bitbucket Repository to ArgoCD

In Bitbucket, open the target repository.

  1. Click the Clone button.
  2. Copy the HTTPS URL exactly as it appears (e.g., https://bitbucket.org/workspace/repository.git).

Step 3: Add Bitbucket Repo to ArgoCD

  1. You can add the repository through ArgoCD UI or CLI by using:
  2. Repository URL: The clone URL copied from Bitbucket.
  3. Username: Your Bitbucket username
  4. Password: Your app password or API token.

Step 4: Create and Sync ArgoCD Application

  1. In ArgoCD UI or CLI, create a new application specifying:
    • Source repo URL (your Bitbucket repo)
    • Target revision (branch, tag, or commit)
    • Path within repo where manifests are located
    • Kubernetes cluster and namespace for deployment
  2. Sync the application to deploy manifests from Bitbucket.

Troubleshooting Tips

  • If connection status fails, verify:
  • Correct repo URL format (HTTPS, no embedded credentials).
  • Use username not just email, check to make sure.
  • Network access from ArgoCD to Bitbucket.
  • ArgoCD version is 2.5+ for proper API token support.
  • Check argocd-repo-server logs for specific error messages.

References

This guide provides the comprehensive steps and best practices to integrate Bitbucket with ArgoCD for secure, automated Kubernetes deployments managing your applications declaratively through GitOps. If you follow these steps, you will achieve a seamless CI/CD workflow between Bitbucket and your Kubernetes cluster managed by ArgoCD.

Top comments (0)