Bitbucket Post Webhook for Jenkins, Azure DevOps

Trigger GitHub workflows

Trigger GitHub workflows from Bitbucket On-Premise


In order to trigger GitHub workflows from Bitbucket On-Premise (Server or Data Center) you need to configure the Post Webhooks for Bitbucket plugin to send the GitHub-specific payload and authenticate the caller.

Create the GitHub personal access token

Ensure that the token has permission to trigger the workflows.

Store it in the token field.

image-20231129-134606.png

Select payload type as GitHub

image-20231129-134326.png

Ensure the URL matches the expected GitHub format

The URL should be in the following format https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME_SLUG}/actions/workflows/{WORKFLOW.YML_FILE}/dispatches

Where:

  • REPO_OWNER is the GitHub org or user that owns the repository where the workflow is stored.

  • REPO_NAME_SLUG is the GitHub repository slug (the one in the URL).

  • WORKFLOW.YML_FILE is the name of the file where GitHub workflow is defined. F.e. main-workflow.yml

Workflow example

name: manual workflow
on:
  workflow_dispatch:
    inputs:
      eventType:
        description: 'event type'
        required: true
        type: string
      projectKey:
        description: 'project key'
        required: true
        type: string
      repositorySlug:
        description: 'repository slug'
        required: true
        type: string
      branch:
        description: 'branch name'
        required: true
        type: string
  jobs:
    greet:
      runs-on: ubuntu-latest
      steps:
        - name: send greeting
          run: echo "Event type: ${{inputs.eventType}}, Repo: ${{inputs.projectKey}}/${{inputs.repositorySlug}}"

As you see in the example GitHub workflow, it has defined some inputs and they are used in the steps of a job.


Updated: