1ec7525bf4
## 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:
|
||
---|---|---|
.github | ||
.vscode | ||
.woodpecker | ||
agent | ||
cli | ||
cmd | ||
contrib/woodpecker-test-repo/.woodpecker | ||
docker | ||
docs | ||
nfpm | ||
pipeline | ||
server | ||
shared | ||
version | ||
web | ||
woodpecker-go | ||
.cspell.json | ||
.ecrc | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.gitpod.yml | ||
.golangci.yaml | ||
.hadolint.yaml | ||
.markdownlint.yaml | ||
.mockery.yaml | ||
.pre-commit-config.yaml | ||
.prettierignore | ||
.prettierrc.json | ||
.yamllint.yaml | ||
CHANGELOG.md | ||
docker-compose.example.yaml | ||
docker-compose.gitpod.yaml | ||
flake.lock | ||
flake.nix | ||
go.mod | ||
go.sum | ||
LICENSE | ||
Makefile | ||
README.md | ||
release-config.ts |
Woodpecker
Woodpecker is a simple yet powerful CI/CD engine with great extensibility.
🫶 Support
Please consider donating and become a backer. 🙏 [Become a backer]
📖 Documentation
✨ Contribute
📣 Translate
We use an own Weblate instance at translate.woodpecker-ci.org.
👋 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
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.