Skip to content

Bitbucket Server

Bitbucket Server event-source programmatically configures webhooks for projects on Bitbucket Server and helps sensor trigger the workloads on events.

Event Structure

The structure of an event dispatched by the event-source over the eventbus looks like following,

        {
            "context": {
              "type": "type_of_event_source",
              "specversion": "cloud_events_version",
              "source": "name_of_the_event_source",
              "id": "unique_event_id",
              "time": "event_time",
              "datacontenttype": "type_of_data",
              "subject": "name_of_the_configuration_within_event_source"
            },
            "data": {
               "body": "Body is the Bitbucket Server event payload",
               "headers": "Headers from the Bitbucket Server event",
            }
        }

Specification

Bitbucket Server event-source specification is available here.
Example event-source yaml file is here.

Setup

  1. Create an API token if you don't have one. Follow instructions to create a new Bitbucket Server API Token. Grant it the Projects: Admin permissions.

  2. Base64 encode your API token key.

    echo -n <api-token-key> | base64
    
  3. Create a secret called bitbucketserver-access that contains your encoded Bitbucket Server API token. You can also include a secret key that is encoded with base64 for your webhook if any.

    apiVersion: v1
    kind: Secret
    metadata:
      name: bitbucketserver-access
    type: Opaque
    data:
      token: <base64-encoded-api-token-from-previous-step>
      secret: <base64-encoded-webhook-secret-key>
    
  4. Deploy the secret into K8s cluster.

    kubectl -n argo-events apply -f bitbucketserver-access.yaml
    
  5. The event-source for Bitbucket Server creates a pod and exposes it via service. The name for the service is in <event-source-name>-eventsource-svc format. You will need to create an Ingress or Openshift Route for the event-source service so that it can be reached from Bitbucket Server. You can find more information on Ingress or Route online.

  6. Create the event source by running the following command. You can use the example event-source yaml file from here but make sure to replace the url field and to modify the repositories list with your own repos.

    kubectl apply -n argo-events -f <event-source-file>
    
  7. Go to Webhooks under your project settings on Bitbucket Server and verify the webhook is registered. You can also do the same by looking at the event-source pod logs.

  8. Create the sensor by running the following command.

    kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/master/examples/sensors/bitbucketserver.yaml
    
  9. Make a change to one of your project files and commit. It will trigger an argo workflow.

  10. Run argo list to find the workflow.

Troubleshoot

Please read the FAQ.

Back to top