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

While displaying list of work items, can we display latest 5/10 work items as release notes having limitation of 5000 characters in App center #1591

Closed
mislekush opened this issue Feb 6, 2024 · 5 comments

Comments

@mislekush
Copy link

Azure DevOps Extensions

Generate Release Notes (Node Cross Platform)

Is your feature request related to a problem? Please describe.

Yaml template which is describing Work items and Pull request showing all items and pull request in release notes.
my requirement is latest 5 items to be displayed in release notes

Describe the solution you'd like

We can loop through work items and get the latest 5 elements.

Describe alternatives you've considered

No response

Additional context

No response

@rfennell
Copy link
Owner

rfennell commented Feb 6, 2024

You don't need an enhancement of the task, you can write it yourself using the customization options available.

Basically you write your own JavaScript based module to implement your own loop See this loop sample that loops with sort. You could modify this exit after returning a fixed number of items.

See this part of WIKI on using extensions

@mislekush
Copy link
Author

Thanks Richard for your reply.
As per your suggestion I have used customHandlebarsExtensionCode however desired output not achieved.
can you help me to get the desired output,
below is current code and wrong output

         templateLocation: 'InLine'
          customHandlebarsExtensionCode: |
              module.exports = {slice_array(array) {
                if(array.length > 4)
                {
                  return array.slice(0, 5);
                }
                else
                {
                  return array;
                }
              }};
          inlinetemplate: |
            **Work Items**
            |Id|Type|Title|
            |-|-|-|
            {{#slice_array this.workItems}}
            |{{this.id}}|{{lookup this.fields 'System.WorkItemType'}}|[{{lookup this.fields 'System.Title'}}]({{replace this.url "_apis/wit/workItems" "_workitems/edit"}})|
            {{/slice_array}}

            **Pull Requests**
            {{#slice_array pullRequests}}
            * [{{this.title}}]({{replace (replace this.url "_apis/git/repositories" "_git") "pullRequests" "pullRequest"}})
            {{/slice_array}}

Output:
image

@rfennell
Copy link
Owner

I think you module needs to be more like https://github.com/rfennell/AzurePipelines/blob/main/SampleTemplates/XplatGenerateReleaseNotes%20(Node%20based)/Version%203%20(and%20later)/each_with_sort_by_field.js

passing the array back as an enumerable item

@mislekush
Copy link
Author

Thank you very much Richard.
solution suggested by you worked for me.

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