3.5. Using Pipelines as Code with Bitbucket Data Center


If your organization or project uses Bitbucket Data Center as the preferred platform, you can use Pipelines as Code for your repository with a webhook on Bitbucket Data Center.

Prerequisites

  • Ensure that Pipelines as Code is installed on the cluster.
  • Generate a personal access token as the manager of the project on Bitbucket Data Center, and save a copy of it in an alternate location.

    注記
    • The token must have the PROJECT_ADMIN and REPOSITORY_ADMIN permissions.
    • The token must have access to forked repositories in pull requests.

Procedure

  1. On your OpenShift cluster, extract the public URL of the Pipelines as Code controller.

    $ echo https://$(oc get route -n openshift-pipelines pipelines-as-code-controller -o jsonpath='{.spec.host}')
  2. On Bitbucket Data Center, perform the following steps:

    1. Use the left navigation pane of your Bitbucket Data Center repository to go to Repository settings –> Webhooks and click Add webhook.
    2. Set a Title. For example, "Pipelines as Code".
    3. Set the URL to the Pipelines as Code controller public URL.
    4. Add a webhook secret and save a copy of it in an alternate location. If you have openssl installed on your local machine, generate a random secret using the following command:

      $ openssl rand -hex 20
    5. Select the following events:

      • Repository: Push
      • Repository: Modified
      • Pull Request: Opened
      • Pull Request: Source branch updated
      • Pull Request: Comment added
    6. Click Save.
  3. On your OpenShift cluster, create a Secret object with the app password in the target namespace.

    $ oc -n target-namespace create secret generic bitbucket-datacenter-webhook-config \
      --from-literal provider.token="<PERSONAL_TOKEN>" \
      --from-literal webhook.secret="<WEBHOOK_SECRET>"
  4. Create a Repository CR.

    Example: Repository CR

    apiVersion: "pipelinesascode.tekton.dev/v1alpha1"
    kind: Repository
    metadata:
      name: my-repo
      namespace: target-namespace
    spec:
      url: "https://bitbucket.com/workspace/repo"
      git_provider:
        url: "https://bitbucket.datacenter.api.url/rest" 
    1
    
        user: "<BITBUCKET_USERNAME>" 
    2
    
        secret: 
    3
    
          name: "bitbucket-datacenter-webhook-config"
          key: "provider.token" # Set this if you have a different key in your secret
        webhook_secret:
          name: "bitbucket-datacenter-webhook-config"
          key: "webhook.secret" # Set this if you have a different key for your secret

    1
    Ensure that you have the right Bitbucket Data Center API URL without the /api/v1.0 suffix. Usually, the default install has a /rest suffix.
    2
    You can only reference a user by the ACCOUNT_ID in an owner file.
    3
    Pipelines as Code assumes that the secret referred in the git_provider.secret spec and the Repository CR is in the same namespace.
    注記

    The tkn pac create and tkn pac bootstrap commands are not supported on Bitbucket Data Center.

Additional resources

Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る