-
Story
-
Resolution: Done
-
Major
-
None
-
4
-
False
-
-
False
-
-
Feature
-
-
-
Pipelines SprintCrookshanks262, Pipelines Sprint Crookshanks 3, Pipelines Sprint Crookshanks 4, Pipelines Sprint Crookshank 27, Pipelines Sprint Crookshank 28
Story (Required)
As a DevOps engineer trying to manage CI/CD pipelines I want to avoid duplicate pipeline runs when a commit appears in both a push event and a pull request.
This feature improves efficiency by preventing unnecessary duplicate pipeline runs, reducing resource usage and making the CI/CD process clearer for users. It implements the same behavior as Jenkins multi-branch pipelines, which is a familiar workflow for many DevOps teams.
Background (Required)
Currently, when a user pushes a branch that is part of an open pull request, Pipelines-as-Code triggers duplicate pipeline runs - one for the push event and another for the pull request event. This causes:
- Unnecessary resource consumption
- Confusion in CI/CD status reporting
- Potential race conditions between competing pipeline runs
- Inefficient use of cluster resources
This behavior differs from other CI systems like Jenkins multi-branch pipelines, which intelligently skip push events if they're part of a pull request.
Out of scope
- Implementing this feature for providers other than GitHub (future enhancement)
- Modifying the behavior for push events that aren't part of pull requests
- Adding configuration options beyond the basic toggle
Approach (Required)
The implementation requires:
1. Add a new configuration setting to control the feature:
```yaml
- Settings struct addition
SkipPushEventForPRCommits bool `default:"true" json:"skip-push-event-for-pr-commits"`
```
2. Create a helper function to check if a push commit is part of an open PR:
```go
func (v *Provider) isCommitPartOfPullRequest(ctx context.Context, sha, org, repo string) (bool, int, error)
```
3. Modify push event handling to skip processing when a commit is part of a PR:
```go
// In processEvent function for push events
if v.pacInfo.SkipPushEventForPRCommits {
isPartOfPR, prNumber, err := v.isCommitPartOfPullRequest(ctx, sha, org, repoName)
if err != nil
if isPartOfPR
{ v.Logger.Infof("Skipping push event for commit %s as it belongs to pull request #%d", sha, prNumber) return nil, fmt.Errorf("commit %s is part of pull request #%d, skipping push event", sha, prNumber) }}
```
4. Update configuration documentation in ConfigMap and settings documentation
Dependencies
- No external dependencies
- Requires GitHub API access to query pull requests and commits
Acceptance Criteria (Mandatory)
1. When a commit is pushed to a branch that has an open PR:
- The system should check if the commit exists in an open PR
- If found, the push event should be skipped with an appropriate log message
- The PR pipeline should still run normally
2. When a commit is pushed to a branch without an open PR:
- The push event should be processed normally
3. The feature should be configurable:
- Default to enabled (`true`)
- Can be disabled by setting `skip-push-event-for-pr-commits: "false"` in the ConfigMap
4. Documentation must be updated:
- ConfigMap documentation explains the feature
- Settings documentation describes the new option
5. Performance impact:
- The GitHub API calls should not significantly impact system performance
- Should handle repositories with many open PRs gracefully
INVEST Checklist
✓ Dependencies identified
✓ Blockers noted and expected delivery timelines set
✓ Design is implementable
✓ Acceptance criteria agreed upon
✗ Story estimated
Done Checklist
- Code is completed, reviewed, documented and checked in
- Unit and integration test automation have been delivered and running cleanly in continuous integration/staging/canary environment
- Continuous Delivery pipeline(s) is able to proceed with new code included
- Customer facing documentation, API docs etc. are produced/updated, reviewed and published
- Acceptance criteria are met