A common request for my Generate Release Notes Tasks is to enrich the data available beyond basic build, work item and commit/changeset details. I have resisted these requests as it felt like a never ending journey to start. However, I have now relented and added the option to see any pull request information available.
This feature is limited, you obviously have to be using artifacts that linked to a Git repo, and also the Git repo have to on an Azure DevOps hosted repository. This won’t meet everyone’s needs but it is a start.
What was already available
Turns out there was already a means to get a limited set of PR details from a build. You used the form
**Build Trigger PR Number**: ${buildDetails.triggerInfo['pr.number']}
or in handlebars format
**Build Trigger PR Number**: {{lookup buildDetails.triggerInfo 'pr.number'}}
The improvements
That said I have improved the options. There is now a new `prDetails` object available to the template.
If you use the dump option
${JSON.stringify(prDetails)}
You can see the fields available
{
"repository": {
"id": "bebd0ae2-405d-4c0a-b9c5-36ea94c1bf59",
"name": "VSTSBuildTaskValidation",
"url": "https://richardfennell.visualstudio.com/670b3a60-2021-47ab-a88b-d76ebd888a2f/_apis/git/repositories/bebd0ae2-405d-4c0a-b9c5-36ea94c1bf59",
"project": {
"id": "670b3a60-2021-47ab-a88b-d76ebd888a2f",
"name": "GitHub",
"description": "A container for GitHub CI/CD processes",
"url": "https://richardfennell.visualstudio.com/_apis/projects/670b3a60-2021-47ab-a88b-d76ebd888a2f",
"state": "wellFormed",
"revision": 411511726,
"visibility": 2,
"lastUpdateTime": "2019-10-10T20:35:51.85Z"
},
"size": 9373557,
"remoteUrl": "https://richardfennell.visualstudio.com/DefaultCollection/GitHub/_git/VSTSBuildTaskValidation",
"sshUrl": "richardfennell@vs-ssh.visualstudio.com:v3/richardfennell/GitHub/VSTSBuildTaskValidation",
"webUrl": "https://richardfennell.visualstudio.com/DefaultCollection/GitHub/_git/VSTSBuildTaskValidation"
},
"pullRequestId": 4,
"codeReviewId": 4,
"status": 1,
"createdBy": {
"displayName": "Richard Fennell (Work MSA)",
"url": "https://spsprodeus24.vssps.visualstudio.com/Ac0efb61e-a937-42a0-9658-649757d55d46/_apis/Identities/b1fce0e9-fbf4-4202-bc09-a290def3e98b",
"_links": {
"avatar": {
"href": "https://richardfennell.visualstudio.com/_apis/GraphProfile/MemberAvatars/aad.NzQzY2UyODUtN2Q0Ny03YjNkLTk0ZGUtN2Q0YjA1ZGE5NDdj"
}
},
"id": "b1fce0e9-fbf4-4202-bc09-a290def3e98b",
"uniqueName": "bm-richard.fennell@outlook.com",
"imageUrl": "https://richardfennell.visualstudio.com/_api/_common/identityImage?id=b1fce0e9-fbf4-4202-bc09-a290def3e98b",
"descriptor": "aad.NzQzY2UyODUtN2Q0Ny03YjNkLTk0ZGUtN2Q0YjA1ZGE5NDdj"
},
"creationDate": "2020-04-04T10:44:59.566Z",
"title": "Added test.txt",
"description": "Added test.txt",
"sourceRefName": "refs/heads/branch2",
"targetRefName": "refs/heads/master",
"mergeStatus": 3,
"isDraft": false,
"mergeId": "f76a6556-8b4f-44eb-945a-9350124f067b",
"lastMergeSourceCommit": {
"commitId": "f43fa4de163c3ee0b4f17b72a659eac0d307deb8",
"url": "https://richardfennell.visualstudio.com/670b3a60-2021-47ab-a88b-d76ebd888a2f/_apis/git/repositories/bebd0ae2-405d-4c0a-b9c5-36ea94c1bf59/commits/f43fa4de163c3ee0b4f17b72a659eac0d307deb8"
},
"lastMergeTargetCommit": {
"commitId": "829ab2326201c7a5d439771eef5a57f58f94897d",
"url": "https://richardfennell.visualstudio.com/670b3a60-2021-47ab-a88b-d76ebd888a2f/_apis/git/repositories/bebd0ae2-405d-4c0a-b9c5-36ea94c1bf59/commits/829ab2326201c7a5d439771eef5a57f58f94897d"
},
"lastMergeCommit": {
"commitId": "53f393cae4ee3b901bb69858c4ee86cc8b466d6f",
"author": {
"name": "Richard Fennell (Work MSA)",
"email": "bm-richard.fennell@outlook.com",
"date": "2020-04-04T10:44:59.000Z"
},
"committer": {
"name": "Richard Fennell (Work MSA)",
"email": "bm-richard.fennell@outlook.com",
"date": "2020-04-04T10:44:59.000Z"
},
"comment": "Merge pull request 4 from branch2 into master",
"url": "https://richardfennell.visualstudio.com/670b3a60-2021-47ab-a88b-d76ebd888a2f/_apis/git/repositories/bebd0ae2-405d-4c0a-b9c5-36ea94c1bf59/commits/53f393cae4ee3b901bb69858c4ee86cc8b466d6f"
},
"reviewers": [],
"url": "https://richardfennell.visualstudio.com/670b3a60-2021-47ab-a88b-d76ebd888a2f/_apis/git/repositories/bebd0ae2-405d-4c0a-b9c5-36ea94c1bf59/pullRequests/4",
"supportsIterations": true,
"artifactId": "vstfs:///Git/PullRequestId/670b3a60-2021-47ab-a88b-d76ebd888a2f%2fbebd0ae2-405d-4c0a-b9c5-36ea94c1bf59%2f4"
}
In templates this new object could be is used
**PR Title **: ${prDetails.title}
or in handlebars format.
**PR Details**: {{prDetails.title}}
It will be interesting to here feedback from the real world as opposed to test harnesses