I'm looking for advice on efficient build practices when using tools that automatically increment version numbers, like `gradle-release` or `npm version`. In our setup, we have a multi-branch pipeline with webhook events triggering builds when changes are pushed to the primary branch. However, when the build automation updates the version and pushes it back to the primary branch, it unintentionally triggers another build. We've implemented shared library code to abort builds based on the author or commit message, but it feels clunky and makes the last build appear aborted.
I've read that the `github-scm-trait-commit-skip` and `bitbucket-scm-trait-commit-skip` plugins only filter change request events, meaning that push events to non-pull requests will always run, which seems counterproductive for preventing these extra builds. Am I approaching the release build process incorrectly? If I want to trigger a release build only after PR approval, what are the best practices others are following that I might be missing? Here's a quick overview of our flow:
1. PR creation leads to Jenkins checking out and merging with main to build and test.
2. If the PR is approved, we merge it with main, remove "dev/SNAPSHOT" from the version, and build the artifact.
3. Then we commit and push the release version, increment the version for future development, and push again to main. Deploys are managed through JIRA or manual Ansible triggers.
1 Answer
We handle it by doing staging builds once a feature is merged into the main branch. For release builds, we only trigger them on tagged commits in the main branch. So the flow goes like this: PR goes in, tests run; if they pass, it gets staged. If the staging pass gets approved, we release it. We add [skip ci] to the commit that merges, so that prevents another build from triggering unnecessarily. Once approved, we bump the version and tag the release, which ultimately triggers the deployment.
Thanks for that breakdown! Just to clarify, does the PR testing include an actual build used for validation? And when does the version increment happen during your process?