Giter Site home page Giter Site logo

Comments (8)

ronnetzer avatar ronnetzer commented on May 18, 2024 1

@pvdlg Is there any plan to add support to azure DevOps?
Currently, I'm unable to link issues correctly as <repository> isn't part of the url.
Azure formats are:
commit: <host>/<owner>/_git/<repository>/commit/<commit-sha>
issue: <host>/<owner>/_workitems/edit/<issue-number>

the <host> will usually be <organization>.visualstudio.com.

also ssh format is a bit different:
<organization>@vs-ssh.visualstudio.com:v3/<organization>/<owner>/<repository>

edit:
just sharing the solution if anyone else also has this issue

module.export = {
  ...,
  plugins: [
    ...,
    ['@semantic-release/release-notes-generator', {
      preset: 'angular',
      writerOpts: {
        finalizeContext: function(context) {
          return {
            ...context,
            repository: null,
            repoUrl: '<host>/<owner>',
            commit: '_git/<repository>/commit',
            issue: '_workitems/edit'
          };
        }
      }
    }]
  ]
}

from release-notes-generator.

faceless7171 avatar faceless7171 commented on May 18, 2024 1

For me solution from @nausaf didn't work either. The one I came up with:

[
      '@semantic-release/release-notes-generator',
      {
        preset: 'conventionalcommits',
        presetConfig: {
          ...,
        issueUrlFormat: `${process.env.SYSTEM_COLLECTIONURI}${process.env.SYSTEM_TEAMPROJECT}/_workitems/edit/{{id}}`,
        commitUrlFormat: `${process.env.SYSTEM_COLLECTIONURI}${process.env.SYSTEM_TEAMPROJECT}/_git/{{repository}}/commit/{{hash}}`
        },
        writerOpts: {
          finalizeContext: function (context) {
            return {
              ...context,
              repository: process.env.BUILD_REPOSITORY_NAME,
              repoUrl: process.env.BUILD_REPOSITORY_URI,
              commit: `_git/<repository>/commit`,
              issue: '_workitems/edit',
            };
          },
        },
        parserOpts: {
          mergePattern:
            '^Merged PR (\\d+): (\\w*)(?:\\(([\\w\\$\\.\\-\\* ]*)\\))?\\: (.*)$',
          mergeCorrespondence: ['id', 'type', 'scope', 'subject'],
          noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'],
        },
    },
],

from release-notes-generator.

pvdlg avatar pvdlg commented on May 18, 2024

I would prefer to not add a new option and instead improve the algorithm to detect Azure URLs and generate changelogContext properly.

from release-notes-generator.

neist avatar neist commented on May 18, 2024

That's fair. The only reason I suggested to do it through changelogContext, was because simply detecting and extending hosts-config.js will not make it work correctly. It's still necessary to provide custom partials to conventional-commits-writer in order to handle the non-standard URL format Azure DevOps is using. I believe this situation is an edge-case and changelogContext provides a needed "escape hatch".

from release-notes-generator.

pvdlg avatar pvdlg commented on May 18, 2024

Can you provide an example of the edge case you are talking about? Like in which case we won't be able to determine all the values for changelogContext based on the repository URL?

from release-notes-generator.

pvdlg avatar pvdlg commented on May 18, 2024

Closing as no answer was provided

from release-notes-generator.

patr00n avatar patr00n commented on May 18, 2024

@pvdlg default issue link format isn't suitable for Azure DevOps, because issues there don't belong to repositories.
Here is the actual pattern: https://dev.azure.com/<owner>/<project>/_workitems/edit/<issue_number>/ I think it can be useful to add a property that can accept full issues path.
So could you please reopen this issue?

from release-notes-generator.

nausaf avatar nausaf commented on May 18, 2024

ronnetzer's solution didn't work for me. I also tried setting repository and repoUrl to different values which didn't work either:

writerOpts: {
          finalizeContext: function (context) {
            return {
              ...context,
              repository: process.env.SYSTEM_TEAMPROJECT,
              repoUrl: process.env.SYSTEM_COLLECTIONURI,
              commit: '_git/<repository>/commit',
              issue: '_workitems/edit',
            };
          },
        },

This could be because I am using preset: 'conventionalcommits' instead of preset: 'angular'.

What did work was adding issueUrlFormat and commitUrlFormat to presetConfig in configuration of @semantic-release/release-notes-generator, as follows:

...,
[
      '@semantic-release/release-notes-generator',
      {
        preset: 'conventionalcommits',
        presetConfig: {
            ...,
            issueUrlFormat: `${process.env.SYSTEM_COLLECTIONURI}{{repository}}/_workitems/edit/{{id}}/`,
          commitUrlFormat: `${process.env.SYSTEM_COLLECTIONURI}{{repository}}/_git/{{repository}}/commit/{{hash}}`,
        },
        writerOpts: {
          finalizeContext: function (context) {
            return {
              ...context,
              repository: process.env.SYSTEM_TEAMPROJECT,
              repoUrl: process.env.SYSTEM_COLLECTIONURI,
              commit: '_git/<repository>/commit',
              issue: '_workitems/edit',
            };
          },
        },
        //parserOpts really does need to be duplicated here
        //(declaring it in the commitAnalyzer plugin once is not enough)
        //probabaly because release-notes-generator too has to parse
        //the commits
        parserOpts: {
          mergePattern:
            '^Merged PR (\\d+): (\\w*)(?:\\(([\\w\\$\\.\\-\\*]*)\\))?\\: (.*)$',
          mergeCorrespondence: ['id', 'type', 'scope', 'subject'],
          noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'],
        },
    },
],

Note that I still need that writerOpts even if it doesn't work as if I take it out the generated release notes do not have commit link nor the issue link. This would happen even if I replace all references to {{repository}} in issueUrlFormat and commitUrlFormat with actual value of repository (${process.env.SYSTEM_TEAMPROJECT}).

By the way, expressions like process.env.SYSTEM_TEAMPROJECT evaluate to Azure Pipelines predefined variables like System.TeamProject. As the predefined variables page states:

In YAML pipelines, you can reference predefined variables as environment variables. For example, the variable Build.ArtifactStagingDirectory becomes the variable BUILD_ARTIFACTSTAGINGDIRECTORY.

from release-notes-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.