This Python script creates a Flask application to act as a webhook for handling Bitbucket repository events.
- Technology: Flask web framework, Python.
- Purpose: Respond to Bitbucket webhook events with specific actions.
- Primary Actions: Execute
git pull
commands and update commit statuses in Bitbucket.
- Endpoint:
/update
- Supported Methods:
GET
,POST
- Payload Handling: Parses JSON payload from Bitbucket webhook.
- Event Handling:
- Push to Master Branch: Executes
git pull
and updates commit status when changes are pushed to themaster
branch. - Pull Request Merged to Master: Executes
git pull
and updates commit status when a pull request is merged into themaster
branch.
- Push to Master Branch: Executes
- Response: Returns a success message with the commit ID.
- Action: Executes
git pull
in the specified directory (/root/repo
). - Response: Returns 'Success'.
- Endpoint:
/generate
- Supported Methods:
GET
,POST
- Payload Handling: Parses JSON payload from Bitbucket webhook.
- Event Handling:
- Push to Release Branch: Executes
build.py
which rebuilds branch - Pull Request Merged to Release: Executes
build.py
which rebuilds the content when a PR is merged to 'release' branch of a documentation repo
- Push to Release Branch: Executes
- Response: Returns a success.
- Action: Executes
build.py
which rebuilds all branches. - Response: Returns 'Success'.
- Function:
update_commit_status
- Purpose: Makes an API call to Bitbucket to update the commit's build status.
- Parameters: Includes workspace, repository slug, commit ID, state, description, and an access token.