Woodpecker is a community fork of the Drone CI system.
Find a file
Joan Flotats 047eb19d42
Change Bitbucket PR hook to point the source branch, commit & ref (#3965)
## Description

This is the first fix for: https://github.com/woodpecker-ci/woodpecker/issues/3932

Change the Pull Request hook parser to return the source commit, branch, and ref instead of the destination. Right now, the workflow pulls the destination configuration and code. It should pull the source configuration and code to verify that the configuration and code work as expected before merging the changes.

In case of the close event, the hook parser returns the destination branch, ref and merge commit. Usually, the contributor automatically deletes the source branch after merging the changes to the destination branch. Using the source values will cause the workflow to fail.

After the changes, Woodpecker will correctly download the workflow from the source branch (Pull Request commit), but it will fail to clone the repository. This issue is related to the commit format returned by the Bitbucket webhook. This inconsistency has already been reported: https://jira.atlassian.com/browse/BCLOUD-21201. The webhook returns a short SHA. The problem is that the `git fetch` command requires the full SHA. 

A workaround for this issue is to use the ref to fetch the code:

```yaml
clone:
  git:
    image: woodpeckerci/plugin-git
    settings:
      ref: ${CI_COMMIT_REF}
```

This is not ideal, because the Pull Request head won't always match the workflow commit, but it solves 80% of the event use cases (e.g. trigger a pull request workflow on change). This workaround won't work when re-running a previous workflow pointing to another commit, it will pull the last commit, not the previous one.

## Solutions

The solution proposed by the community is to retrieve the full SHA from the Bitbucket API using the short one. This solution has drawbacks:
- The Bitbucket API rate limit is 1000 req/h. This solution will reduce the maximum number of workflow runs per hour.
- It requires a braking change in the forges interface because the ´Hook(...)´ method does not have an instance of the HTTP Client. 

We propose to allow the git plugin to fetch the source code from a URL. The Bitbucket returns a link pointing to the commit. 

This proposal only requires a small change to the git plugin:
- Add a new optional parameter (e.g. CommitLink)
- Add a clause to the following conditional: 7ac9615f40/plugin.go (L79C1-L88C3)
```go
if p.Pipeline.CommitLink != "" {...}
```
Git commands:
```shell
$ git fetch --no-tags --depth=1 --filter=tree:0 https://bitbucket.org/workspace/repo/commits/692972aabfec
$ git reset --hard -q 692972aabfec # It works with the short SHA
```
Woodpecker will set CommitLink to a blank string for the other forges, but Bitbuckket will use the one returned by the webhook.
2024-07-23 16:58:38 +02:00
.github Update plugin-git and add renovate trigger (#3901) 2024-07-13 13:43:13 -07:00
.vscode Fix vscode settings (#3880) 2024-07-09 02:56:42 -07:00
.woodpecker chore(deps): update woodpeckerci/plugin-ready-release-go docker tag to v1.2.0 (#3954) 2024-07-21 18:42:28 +02:00
agent Gracefully shutdown agent (#3895) 2024-07-14 01:06:20 +02:00
cli Make cli plugin log purge recognize steps by name (#3953) 2024-07-21 11:36:01 +02:00
cmd Remove WOODPECKER_DEV_OAUTH_HOST and WOODPECKER_DEV_GITEA_OAUTH_URL (#3961) 2024-07-23 14:25:39 +02:00
contrib/woodpecker-test-repo/.woodpecker Cleanups + prefer .yaml (#3069) 2024-01-11 18:43:54 +01:00
docker Update alpine package dep for docker images (#3917) 2024-07-16 21:39:23 +02:00
docs Remove WOODPECKER_DEV_OAUTH_HOST and WOODPECKER_DEV_GITEA_OAUTH_URL (#3961) 2024-07-23 14:25:39 +02:00
nfpm build: fix nfpm path for server binary (#3246) 2024-01-21 23:08:53 +01:00
pipeline Remove deprecated pipeline settings (#3916) 2024-07-23 13:06:47 +02:00
server Change Bitbucket PR hook to point the source branch, commit & ref (#3965) 2024-07-23 16:58:38 +02:00
shared Migrate to github.com/urfave/cli/v3 (#2951) 2024-07-18 01:26:35 +02:00
version Add godot linter to harmonitze toplevel comments (#3650) 2024-05-13 22:58:21 +02:00
web Fix login via navbar (#3962) 2024-07-23 13:46:22 +02:00
woodpecker-go Global and organization registries (#1672) 2024-07-03 06:33:11 -07:00
.cspell.json cspell lint docs (#3787) 2024-07-22 20:42:00 +02:00
.ecrc Add spellcheck config (#3018) 2024-01-27 21:15:10 +01:00
.editorconfig Use editorconfig-checker (#982) 2022-06-17 12:03:34 +02:00
.gitattributes Fix "check_swagger" step (#2024) 2023-07-20 22:12:32 +02:00
.gitignore Split client into multiple files and add more tests (#3647) 2024-04-26 13:46:55 +02:00
.gitpod.yml Cleanup server env settings (#3670) 2024-05-15 15:45:08 +02:00
.golangci.yaml Exclude mocks from release build (#3831) 2024-06-25 12:23:07 +02:00
.hadolint.yaml Cleanups + prefer .yaml (#3069) 2024-01-11 18:43:54 +01:00
.markdownlint.yaml Add spellcheck config (#3018) 2024-01-27 21:15:10 +01:00
.mockery.yaml Fix make in_docker generate (#3616) 2024-04-15 17:46:44 +02:00
.pre-commit-config.yaml [pre-commit.ci] pre-commit autoupdate (#3862) 2024-07-01 23:50:01 +02:00
.prettierignore Do not run prettier with pre-commit (#3196) 2024-01-14 21:14:00 +01:00
.prettierrc.json Remove old files (#3077) 2023-12-30 15:10:31 +01:00
.yamllint.yaml Add spellcheck config (#3018) 2024-01-27 21:15:10 +01:00
CHANGELOG.md Frontport 2.6.1 changelog (#3956) 2024-07-21 19:49:51 +02:00
docker-compose.example.yaml Cleanups + prefer .yaml (#3069) 2024-01-11 18:43:54 +01:00
docker-compose.gitpod.yaml chore(deps): update gitea/gitea docker tag to v1.22 (#3749) 2024-06-03 07:42:16 +02:00
flake.lock Fix flake add sqlite (#3890) 2024-07-12 11:37:02 -05:00
flake.nix Add blocklist of environment variables who could alter execution of plugins (#3934) 2024-07-18 22:54:29 +02:00
go.mod fix(deps): update golang-packages (#3958) 2024-07-22 18:18:26 +02:00
go.sum fix(deps): update golang-packages (#3958) 2024-07-22 18:18:26 +02:00
LICENSE Check for correct license header (#2137) 2023-08-10 11:06:00 +02:00
Makefile Release windows binaries as zip file (#3906) 2024-07-14 22:59:45 +02:00
README.md Fix spelling in README (#3741) 2024-05-31 22:52:59 +02:00
release-config.ts Add release helper (#1976) 2023-09-07 17:17:17 +02:00

Woodpecker

Woodpecker


Pipeline Status Code coverage Translation status Matrix space Go Report Card go reference GitHub release Docker pulls License: Apache-2.0 OpenSSF best practices pre-commit.ci


Woodpecker is a simple yet powerful CI/CD engine with great extensibility.

woodpecker

🫶 Support

Please consider donating and become a backer. 🙏 [Become a backer]

Open Collective backers

📖 Documentation

https://woodpecker-ci.org/

Contribute

See Contributing Guide

Open in Gitpod

📣 Translate

We use an own Weblate instance at translate.woodpecker-ci.org.

Translation status

👋 Who uses Woodpecker?

Woodpecker is used by itself, multiple well-known companies, organizations like Codeberg, hobbyists and many others.

Leave a comment if you're using it as well.

Also consider using the topic WoodpeckerCI in your repository, so others can learn from your config and use the hashtag #WoodpeckerCI when talking about the project on social media!

Here are some places where people mention Woodpecker:

Stars over time

Stargazers over time

License

Woodpecker is Apache 2.0 licensed with the source files in this repository having a header indicating which license they are under and what copyrights apply.

Files under the docs/ folder are licensed under Creative Commons Attribution-ShareAlike 4.0 International Public License.