'currentBuild.changeSets isn't suitable for gathering list of merged PR's since last CI build: fix or alternatives?
Problem: I need to get a list of merged pull requests (for a single git branch) from github, in jenkins pipeline. Only the ones since the last jenkins build. This branch is checked out during the pipeline so below script works in simple cases:
def changes = currentBuild.changeSets
I then use this to loop and get all the commit ID's, make an API call to get the parent PR titles and use those for notifications "your PR 'title' was included in CI build 'name of job' ".
This works in simple scenario where I set up a test PR and merge it to the branch in between builds, but the following scenario is a problem:
- branch from a 2 month old tag
- make a change
- merge the PR into main results in hundreds of changesets in currentBuild.changeSets during the next build. It looks like it picks up old merges which gives me useless, old, closed PR titles.
- ^above is a realistic dev scenario that need to be pre-empted
I dont fully understand how this works, the documentation isn't helping much: https://javadoc.jenkins-ci.org/hudson/scm/ChangeLogSet.html It's just something you see suggested often here 'use currentBuild.changeSets' so I experimented with it. Im starting to think this doesnt give me enough control and I need to try alternative approaches.
Looking for suggestions and best practices. Guessing Im not the first person with this problem.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
