Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Release Notes from branch takes ALL commits history #1868

Closed
mbalieiro opened this issue Apr 24, 2024 · 3 comments
Closed

Build Release Notes from branch takes ALL commits history #1868

mbalieiro opened this issue Apr 24, 2024 · 3 comments

Comments

@mbalieiro
Copy link

Azure DevOps Extensions

Artifact PR Description

Platform

Azure DevOps Services

Azure DevOps Server (TFS) Version

No response

Extension Version

4

Describe the bug

When I generate a release note in my build pipeline (CheckStage=false) from main branch, it works fine (it takes only the difference between successful builds). But if I create a branch from main, make some commits to that branch and try to build from that branch, it create a release notes of ALL the history of the project.

My configuration:
task: XplatGenerateReleaseNotes@4
displayName: Gerando Release Notes
inputs:
outputfile: '$(Build.ArtifactStagingDirectory)/release-notes/Build-$(Build.BuildNumber).md'
templateLocation: 'File'
templatefile: '$(System.DefaultWorkingDirectory)/release-notes/build-handlebars-template.md'
customHandlebarsExtensionFolder: $(System.DefaultWorkingDirectory)/release-notes/
customHandlebarsExtensionFile: formatarData.js
checkStage: false
sortCS: true
dumpPayloadToConsole: false
dumpPayloadToFile: false
replaceFile: true
getParentsAndChildren: False
getAllParents: False
getIndirectPullRequests: False
maxRetries: '5'
stopOnError: False
considerPartiallySuccessfulReleases: False
checkForManuallyLinkedWI: False
wiqlFromTarget: 'WorkItems'

Is there a way to overcome this behavior?

Repo Steps

  1. Create a branch from main;
  2. Make some commits to that branch;
  3. Try to build from that branch;
  4. It will create a release notes of ALL the history and not with only the commits made to that branch;

Expected Behavior

I expected that the extension backtrack changes to the actual branch of the run until it find the last successful build of that branch. If not find any build, it change to the origin branch and keep looking for a successful build and so on.

Logging Information

Logs from the main branch:

2024-04-18T14:01:56.8976801Z ##[section]Starting: Gerando Release Notes
2024-04-18T14:01:56.8981942Z ==============================================================================
2024-04-18T14:01:56.8982051Z Task : Generate Release Notes (Crossplatform)
2024-04-18T14:01:56.8982123Z Description : Generates a release notes file in a format of your choice from the build or release history
2024-04-18T14:01:56.8982228Z Version : 4.16.13
2024-04-18T14:01:56.8982293Z Author : Black Marble
2024-04-18T14:01:56.8982372Z Help : Version: 4.16.13. More Information
2024-04-18T14:01:56.8982653Z ==============================================================================
2024-04-18T14:01:57.2252356Z Creating Azure DevOps API connections for https://dev.azure.com/bbts-lab/ with 'allowRetries' set to 'true' and 'maxRetries' count to '5'
2024-04-18T14:01:57.2256551Z Creating the credential handler from the OAUTH token
2024-04-18T14:01:57.6870172Z Getting the current build details
2024-04-18T14:01:58.0294310Z Getting artifacts published by the current build
2024-04-18T14:01:58.2117790Z Getting items associated with only the current build
2024-04-18T14:01:58.9550270Z Get the artifacts consumed by the build
2024-04-18T14:01:59.1329744Z Get the file details associated with the commits
2024-04-18T14:01:59.1348706Z Enriched change 4dbd3cec1f4a4c80f2d6de6d2dce5b8e6dc1a2c9 of type TfsGit
2024-04-18T14:01:59.5081476Z Enriched with details of 1 files
2024-04-18T14:01:59.5083228Z Enriched change cdfafeb680caa39f24793fc67e2a919464f2e86b of type TfsGit
2024-04-18T14:01:59.7115027Z Enriched with details of 13 files
2024-04-18T14:01:59.7119386Z Enriched change 37a85cd26e6c5599ef0da9d1335b463d6b17d23a of type TfsGit
2024-04-18T14:02:00.3183674Z Enriched with details of 13 files
2024-04-18T14:02:00.3190034Z Enriched change ed77db9c0f830cff921abfc9f6b757e6719f4f63 of type TfsGit
2024-04-18T14:02:00.5542147Z Enriched with details of 1 files
2024-04-18T14:02:00.5542977Z Get any test details associated with the build
2024-04-18T14:02:03.7709811Z Get any manual test run details associated with the build
2024-04-18T14:02:04.2601771Z Removing duplicate Commits from master list
2024-04-18T14:02:04.2604759Z Expanding the truncated commit messages...
2024-04-18T14:02:04.2605036Z Expanded truncated commit messages 0
2024-04-18T14:02:04.2605292Z Sorting CS by created date
2024-04-18T14:02:04.2605545Z Find any WorkItems linked from GitHub using the AB#123 format
2024-04-18T14:02:04.2607559Z Adding 0 found using AB#123 links in GitHub comments
2024-04-18T14:02:04.2607803Z Removing duplicate WorkItems from master list
2024-04-18T14:02:04.2608925Z Getting tests linked to WorkItems
2024-04-18T14:02:04.2610157Z Checking for user defined WIQL query
2024-04-18T14:02:04.2613561Z No WIQL query parameters defined
2024-04-18T14:02:04.2613982Z Leaving WI in default order as returned by API
2024-04-18T14:02:04.4537340Z The default artifact for the release was not linked to an Azure DevOps Git Repo Pull Request
2024-04-18T14:02:04.4537790Z Getting all completed Azure DevOps Git Repo PRs in the Team Project PSIM
2024-04-18T14:02:04.4538796Z Getting all completed Azure DevOps Git Repo PRs for all repositories
2024-04-18T14:02:04.4539321Z Getting all completed Azure DevOps Git Repo PRs for all refs
2024-04-18T14:02:04.4539916Z Getting associated PRs
2024-04-18T14:02:05.1790142Z Found 256 Azure DevOps PRs in the repo
2024-04-18T14:02:05.1816461Z Checking for PRs associated with the commit ed77db9c0f830cff921abfc9f6b757e6719f4f63
2024-04-18T14:02:05.1820092Z Checking for PRs associated with the commit 37a85cd26e6c5599ef0da9d1335b463d6b17d23a
2024-04-18T14:02:05.1820799Z Checking for PRs associated with the commit cdfafeb680caa39f24793fc67e2a919464f2e86b
2024-04-18T14:02:05.1821162Z Checking for PRs associated with the commit 4dbd3cec1f4a4c80f2d6de6d2dce5b8e6dc1a2c9
2024-04-18T14:02:05.1821698Z Enriching known Pull Requests
2024-04-18T14:02:05.1821984Z Total Builds: [0]
2024-04-18T14:02:05.1822755Z Total Commits: [4]
2024-04-18T14:02:05.1823028Z Total Workitems: [0]
2024-04-18T14:02:05.1823512Z Total Related Workitems (Parent/Children): [0]
2024-04-18T14:02:05.1823806Z Total Release Tests: [0]
2024-04-18T14:02:05.1824269Z Total Tests: [0]
2024-04-18T14:02:05.1824547Z Total Manual Test Runs: [0]
2024-04-18T14:02:05.1825775Z Total Manual Test Configurations: [0]
2024-04-18T14:02:05.1826082Z Total Pull Requests: [0]
2024-04-18T14:02:05.1826568Z Total Indirect Pull Requests: [0]
2024-04-18T14:02:05.1826861Z Total Associated Test WI: [0]
2024-04-18T14:02:05.1827335Z Total Published Artifacts: [0]
2024-04-18T14:02:05.1827622Z Total Consumed Artifacts: [0]
2024-04-18T14:02:05.1828256Z Total WIQL Workitems: [0]
2024-04-18T14:02:05.1828612Z Generating the release notes, the are 1 template(s) to process
2024-04-18T14:02:05.1829848Z Loading template file /home/vsts/work/1/s/release-notes/build-handlebars-template.md
2024-04-18T14:02:05.2024921Z Loading handlebars-helpers extension
2024-04-18T14:02:05.8271130Z Loaded handlebars extension file
2024-04-18T14:02:05.8817796Z Completed processing template
2024-04-18T14:02:05.8820765Z Writing output file /home/vsts/work/1/a/release-notes/Build-2.125.0.md
2024-04-18T14:02:05.8821523Z Finished writing output file /home/vsts/work/1/a/release-notes/Build-2.125.0.md
2024-04-18T14:02:05.8821950Z Output variable 'undefined' set to value of first generated release notes
2024-04-18T14:02:05.9100630Z ##[section]Finishing: Gerando Release Notes

Logs from the release branch based on main and with only one commit:

2024-04-24T19:55:30.5212505Z ##[section]Starting: Gerando Release Notes
2024-04-24T19:55:30.5218174Z ==============================================================================
2024-04-24T19:55:30.5218293Z Task : Generate Release Notes (Crossplatform)
2024-04-24T19:55:30.5218383Z Description : Generates a release notes file in a format of your choice from the build or release history
2024-04-24T19:55:30.5218501Z Version : 4.16.13
2024-04-24T19:55:30.5218570Z Author : Black Marble
2024-04-24T19:55:30.5218658Z Help : Version: 4.16.13. More Information
2024-04-24T19:55:30.5218813Z ==============================================================================
2024-04-24T19:55:30.9425703Z Creating Azure DevOps API connections for https://dev.azure.com/bbts-lab/ with 'allowRetries' set to 'true' and 'maxRetries' count to '5'
2024-04-24T19:55:30.9428851Z Creating the credential handler from the OAUTH token
2024-04-24T19:55:31.4068028Z Getting the current build details
2024-04-24T19:55:31.9181398Z Getting artifacts published by the current build
2024-04-24T19:55:32.0637033Z Getting items associated with only the current build
2024-04-24T19:55:33.4794586Z Get the artifacts consumed by the build
2024-04-24T19:55:33.6344611Z Get the file details associated with the commits
2024-04-24T19:55:33.6347534Z Enriched change 961bcb419a1cce3c1d8991c14464ccba4eec3590 of type TfsGit
2024-04-24T19:55:34.2520189Z Enriched with details of 12 files
2024-04-24T19:55:34.2520477Z Enriched change b2e39a1739fca0aed4dfdb9805ae9802c616e875 of type TfsGit
2024-04-24T19:55:34.4122480Z Enriched with details of 12 files
2024-04-24T19:55:34.4123322Z Enriched change 6f89ef0ef74bf8c3de42e04004ab846527b30f17 of type TfsGit
.
.
.
2024-04-24T19:56:08.2819381Z Enriched with details of 13 files
2024-04-24T19:56:08.2820493Z Enriched change 24da731230725e0429e519607f9805d714819e8d of type TfsGit
2024-04-24T19:56:08.4326718Z Enriched with details of 13 files
2024-04-24T19:56:08.4327148Z Enriched change b7b7ff095f6c5ef56ba32bf86f6c4ba2a087d7f0 of type TfsGit
2024-04-24T19:56:08.5675530Z Enriched with details of 1 files
2024-04-24T19:56:08.5676390Z Enriched change dcdd2575f4557fbce16c4a828a8212f28b641cc4 of type TfsGit
2024-04-24T19:56:08.7212550Z Enriched with details of 9 files
2024-04-24T19:56:08.7213494Z Enriched change e5ac7d5a05834a23776d42fea2f9dc3736351c03 of type TfsGit
2024-04-24T19:56:08.8672398Z Enriched with details of 9 files
2024-04-24T19:56:08.8672760Z Get any test details associated with the build
2024-04-24T19:56:09.3293986Z Get any manual test run details associated with the build
2024-04-24T19:56:09.4750512Z Removing duplicate Commits from master list
2024-04-24T19:56:09.4768925Z Expanding the truncated commit messages...
2024-04-24T19:56:25.7730985Z Expanded truncated commit messages 82
2024-04-24T19:56:25.7731894Z Sorting CS by created date
2024-04-24T19:56:25.7733573Z Find any WorkItems linked from GitHub using the AB#123 format
2024-04-24T19:56:25.7733993Z Adding 0 found using AB#123 links in GitHub comments
2024-04-24T19:56:25.7734353Z Removing duplicate WorkItems from master list
2024-04-24T19:56:25.7736199Z Get details of [103] WIs
2024-04-24T19:56:25.7736544Z Getting full details of WI batch from index: [0] to [103]
2024-04-24T19:56:27.0209562Z Adding [103] items
2024-04-24T19:56:27.0209922Z Getting tests linked to WorkItems
2024-04-24T19:56:27.0214842Z Looking for Tests of WI [119478]
2024-04-24T19:56:27.0217620Z Looking for Tests of WI [118732]
2024-04-24T19:56:27.0220340Z Looking for Tests of WI [118375]
.
.
.
2024-04-24T19:56:27.0222875Z Looking for Tests of WI [118561]
2024-04-24T19:56:27.0346520Z Looking for Tests of WI [113418]
2024-04-24T19:56:27.0347011Z Looking for Tests of WI [113428]
2024-04-24T19:56:27.0347314Z Looking for Tests of WI [113338]
2024-04-24T19:56:27.0347860Z Checking for user defined WIQL query
2024-04-24T19:56:27.0348175Z No WIQL query parameters defined
2024-04-24T19:56:27.0348703Z Leaving WI in default order as returned by API
2024-04-24T19:56:27.1961456Z The default artifact for the release was not linked to an Azure DevOps Git Repo Pull Request
2024-04-24T19:56:27.1962264Z Getting all completed Azure DevOps Git Repo PRs in the Team Project PSIM
2024-04-24T19:56:27.1963001Z Getting all completed Azure DevOps Git Repo PRs for all repositories
2024-04-24T19:56:27.1963428Z Getting all completed Azure DevOps Git Repo PRs for all refs
2024-04-24T19:56:27.1964049Z Getting associated PRs
2024-04-24T19:56:27.9932435Z Found 262 Azure DevOps PRs in the repo
2024-04-24T19:56:27.9932810Z Checking for PRs associated with the commit e5ac7d5a05834a23776d42fea2f9dc3736351c03
2024-04-24T19:56:27.9933519Z Checking for PRs associated with the commit dcdd2575f4557fbce16c4a828a8212f28b641cc4
2024-04-24T19:56:27.9934171Z - PR 14986 matches the commit dcdd2575f4557fbce16c4a828a8212f28b641cc4
2024-04-24T19:56:27.9934507Z Checking for PRs associated with the commit b7b7ff095f6c5ef56ba32bf86f6c4ba2a087d7f0
2024-04-24T19:56:27.9934808Z Checking for PRs associated with the commit 24da731230725e0429e519607f9805d714819e8d
.
.
.
2024-04-24T19:56:28.0019120Z Checking for PRs associated with the commit 6f89ef0ef74bf8c3de42e04004ab846527b30f17
2024-04-24T19:56:28.0019344Z Checking for PRs associated with the commit b2e39a1739fca0aed4dfdb9805ae9802c616e875
2024-04-24T19:56:28.0019788Z Checking for PRs associated with the commit 961bcb419a1cce3c1d8991c14464ccba4eec3590
2024-04-24T19:56:28.0020084Z - PR 16145 matches the commit 961bcb419a1cce3c1d8991c14464ccba4eec3590
2024-04-24T19:56:28.0020264Z Enriching known Pull Requests
2024-04-24T19:57:40.9433442Z Total Builds: [0]
2024-04-24T19:57:40.9433642Z Total Commits: [200]
2024-04-24T19:57:40.9433781Z Total Workitems: [103]
2024-04-24T19:57:40.9433938Z Total Related Workitems (Parent/Children): [0]
2024-04-24T19:57:40.9434118Z Total Release Tests: [0]
2024-04-24T19:57:40.9434252Z Total Tests: [0]
2024-04-24T19:57:40.9434403Z Total Manual Test Runs: [0]
2024-04-24T19:57:40.9434563Z Total Manual Test Configurations: [0]
2024-04-24T19:57:40.9434731Z Total Pull Requests: [58]
2024-04-24T19:57:40.9434882Z Total Indirect Pull Requests: [0]
2024-04-24T19:57:40.9435048Z Total Associated Test WI: [0]
2024-04-24T19:57:40.9435197Z Total Published Artifacts: [0]
2024-04-24T19:57:40.9435361Z Total Consumed Artifacts: [0]
2024-04-24T19:57:40.9435507Z Total WIQL Workitems: [0]
2024-04-24T19:57:40.9671700Z Generating the release notes, the are 1 template(s) to process
2024-04-24T19:57:40.9674932Z Loading template file /home/vsts/work/1/s/release-notes/build-handlebars-template.md
2024-04-24T19:57:40.9888471Z Loading handlebars-helpers extension
2024-04-24T19:57:41.2663658Z Loaded handlebars extension file
2024-04-24T19:57:41.3762617Z Completed processing template
2024-04-24T19:57:41.3763264Z Writing output file /home/vsts/work/1/a/release-notes/Build-2.125.1.md
2024-04-24T19:57:41.3775433Z Finished writing output file /home/vsts/work/1/a/release-notes/Build-2.125.1.md
2024-04-24T19:57:41.3776102Z Output variable 'undefined' set to value of first generated release notes
2024-04-24T19:57:41.4080506Z ##[section]Finishing: Gerando Release Notes

@rfennell
Copy link
Owner

If checkstage=false the WI and CS are retrieved using the calls

 globalCommits = await buildApi.getBuildChanges(teamProject, buildId, "", 5000);
 globalWorkItems = await buildApi.getBuildWorkItemsRefs(teamProject, buildId, 5000);

i.e. gets all the items for the current builds. These Node SDK calls are wrappers for

GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/changes?api-version=7.1-preview.2
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/workitems?api-version=7.1-preview.2

So to diagnose what is going on

  1. Re-run the build with the system.debug=true(or the checkbox for more diags on the run dialog). This will show a lot more detail in the logs
  2. In a browser session authenticated with AzDo, call the REST APIs with the buildid matching run builds and see what is returned,

@mbalieiro
Copy link
Author

If checkstage=false the WI and CS are retrieved using the calls

 globalCommits = await buildApi.getBuildChanges(teamProject, buildId, "", 5000);
 globalWorkItems = await buildApi.getBuildWorkItemsRefs(teamProject, buildId, 5000);

i.e. gets all the items for the current builds. These Node SDK calls are wrappers for

GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/changes?api-version=7.1-preview.2
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/workitems?api-version=7.1-preview.2

So to diagnose what is going on

  1. Re-run the build with the system.debug=true(or the checkbox for more diags on the run dialog). This will show a lot more detail in the logs
  2. In a browser session authenticated with AzDo, call the REST APIs with the buildid matching run builds and see what is returned,

Thanks Richard, indeed the problem is on Get Build Changes API, since it appears it does not work with different branches (https://developercommunity.visualstudio.com/t/build-changes-api-returns-extra-commits/1184419#T-N1203899)

I think it don't have solution for this case since our Branch Strategy depends on create builds from temporary branches (release/vX.XX.XX)

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants