jreleaser / jreleaser

:rocket: Release projects quickly and easily with JReleaser
https://jreleaser.org
Apache License 2.0
944 stars 109 forks source link

[slack] Announce link uses gitlab.com instead of configured private one #268

Closed javydreamercsw closed 3 years ago

javydreamercsw commented 3 years ago

Steps to Reproduce

  1. Configure as below

    <plugin>
    <groupId>org.jreleaser</groupId>
    <artifactId>jreleaser-maven-plugin</artifactId>
    <version>0.4.0</version>
    <configuration>
        <jreleaser>
            <release>
                <gitlab>
                    <!--
                        The user or organization that owns the repository.
                        If unspecified, will read it from the 'origin' git remote.
                    -->
                    <owner>javierortiz</owner>
                    <!--
                        The name of the repository.
                        If unspecified, will read it from the 'origin' git remote.
                    -->
                    <name>${project.build.finalName}</name>
                    <!--
                        The id of the GitLab repository.
                        The parameter is specific to GitLab Releases and could be
                        necessary if the token-owner sees multiple same-named repositories.
    
                    -->
                    <identifier>1861</identifier>
                    <!--
                        The GitLab host url.
                        Defaults to `gitlab.com`.
    
                    -->
                    <host>host</host>
                    <!--
                        Username used for authoring commits. Must have write access to the repository.
    
                    -->
                    <username>javierortiz</username>
                    <!--
                        Drops and creates an existing release with matching tag.
                        May define a `JRELEASER_OVERWRITE` environment variable instead.
                        Defaults to `false`.
                    -->
                    <overwrite>true</overwrite>
                    <!--
                        Appends artifacts to an existing release with matching tag,
                        useful if `overwrite` is set to `false`.
                        May define a `JRELEASER_UPDATE` environment variable instead.
                        Defaults to `false`.
                    -->
                    <update>true</update>
                    <!--
                        Skips creating a tag.
                        Useful when the tag was created externally.
                        May define a `JRELEASER_SKIP_TAG` environment variable instead.
                        Defaults to `false`.
                    -->
                    <skipTag>false</skipTag>
                    <!--
                        The GitLab API endpoint to use.
                        You can skip `/api/v4` as it will be added by default.
                        Defaults to `https://gitlab.com`.
                    -->
                    <apiEndpoint>endpoint</apiEndpoint>
                    <!--
                        Git author used to commit to the repository.
                    -->
                    <commitAuthor>
                        <!--
                             Name used when authoring commits.
                            Defaults to `jreleaserbot`.
                        -->
                        <name>javierortiz</name>
                        <!--
                            E-mail used when authoring commits.
                            Defaults to `jreleaser@kordamp.org`.
                        -->
                        <email>javierortiz@email.com</email>
                    </commitAuthor>
                    <!--
                        Signs commits with the configured credentials.
                        The Signing section must be configured as well.
                        Defaults to `false`.
                    -->
                    <sign>false</sign>
                    <!--
                        Changelog customization.
                    -->
                    <changelog>
                        <!--
                             Disables or enables the changelog.
                            defaults to `true`.
                        -->
                        <enabled>true</enabled>
                        <!--
                            Sorts commits in ascending (oldest first) or descending (newer first).
                            Valid values are>`ASC`, `DESC`.
                            Defaults to `DESC`.
                        -->
                        <sort>DESC</sort>
                        <!--
                            Create explicit markdown links for commit hashes.
                            Defaults to `false`.
                        -->
                        <links>false</links>
                        <!--
                            Enables or disables formatting options.
                            Valid values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
                            Defaults to `NEVER`.
                        -->
                        <formatted>ALWAYS</formatted>
                        <!--
                            The template to use for each change.
                            Defaults to `- {{commitShortHash}} {{commitTitle}} ({{commitAuthor}})`.
    
                        -->
                        <change>- {{commitShortHash}} {{commitTitle}}</change>
                        <!--
                            Path to a template file that defines the contents.
                            Review the available Name Templates.
                            Defaults to `src/jreleaser/templates/changelog.tpl`.
    
                        -->
                        <contentTemplate>src/main/resources/changelog.tpl</contentTemplate>
                        <!--
                            Hide uncategorized commits.
                            Defaults to `false`.
                        -->
                        <hideUncategorized>false</hideUncategorized>
                        <!--
                            A list of labels to be included.
                            Only changes matching this list will be included.
                            Defaults to empty.
    
                        <includeLabels/>-->
                        <!--
                            A list of labels to be excluded.
                            Changes matching this list will be excluded.
                            Defaults to empty.
    
                        <excludeLabels/>-->
                        <!--
                            Defines rules that apply labels to changes.
                            Matchers are evaluated independently; the label will
                            be set if at least one of the matchers meets the criteria.
                        -->
                        <labelers>
                            <labeler>
                                <!--
                                    The label to be applied.
                                -->
                                <label>issue</label>
                                <!--
                                    Matches the text of the first commit line.
                                -->
                                <title>^fix:</title>
                                <!--
                                    Matches the full text of the commit.
                                -->
                                <body>Fixes #</body>
                            </labeler>
                        </labelers>
                        <!--
                            Groups changes by category.
                            Defaults are shown.
                        -->
                        <categories>
                            <category>
                                <title>๐Ÿš€ Features</title>
                                <labelsAsString>feature,enhancement</labelsAsString>
                            </category>
                            <category>
                                <title>๐Ÿ› Bug Fixes</title>
                                <labelsAsString>bug,fix</labelsAsString>
                            </category>
                        </categories>
                        <!--
                            Defines rules for replacing the generated content.
                            Each replacer is applied in order.
    
                        -->
                        <replacers>
                            <replacer>
                                <search>\[chore\]\s</search>
                            </replacer>
                            <replacer>
                                <search>/P14C-(\d+)/g</search>
                                <replace>https://jira.com/browse/P14C-$1</replace>
                            </replacer>
                        </replacers>
                    </changelog>
                    <!--
                        The target branch to use.
                        May define a `JRELEASER_BRANCH` environment variable instead.
                        Defaults to the branch pointed by HEAD.
    
                    -->
                    <branch>master</branch>
                </gitlab>
            </release>
            <!--
    
            -->
            <announce>
                <!--
    
                -->
                <slack>
                    <!--
                        Enable or disable this announcer.
                        Valid values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
                        Defaults to `NEVER`.
    
                    -->
                    <active>ALWAYS</active>
                    <!--
                        Defines the connection timeout in seconds.
                        Defaults to `20`.
    
                    -->
                    <connectTimeout>20</connectTimeout>
                    <!--
                        Defines the read timeout in seconds.
                        Defaults to `60`.
    
                    -->
                    <readTimeout>60</readTimeout>
                    <!--
                        The ApiKey associated with the given account.
                        If left unspecified, the `JRELEASER_SLACK_TOKEN` environment variable must be defined.
    
                    -->
                    <token>${SLACK_TOKEN}</token>
                    <!--
                        The webhook associated with a specific Discord room.
                        If left unspecified, the `JRELEASER_SLACK_WEBHOOK` environment variable must be defined.
    
                    -->
                    <webhook>https://hooks.slack.com/services/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</webhook>
                    <!--
                        The channel where the message will be sent to
                        Defaults to `3announce`.
    
                    -->
                    <channel>#announcement</channel>
                    <!--
                        The announcement message.
                        Review the available Name Templates.
    
                    -->
                    <message>{{projectNameCapitalized}} {{projectVersion}} has been released! {{releaseNotesUrl}}
                    </message>
                </slack>
            </announce>
        </jreleaser>
    </configuration>
    </plugin>
  2. Perform a release or any goal involving annouce

Expected Behaviour

Announcement links to configured GitLab

Actual Behaviour

Links to gitlab.com instead, i.e. https://gitlab.com/javierortiz/project-verison-SNAPSHOT/-/releases/v5.0.8-SNAPSHOT

Environment Information

aalmiray commented 3 years ago

This means {{releaseNotesUrl}} is resolved to the incorrect value. Could you invoke mvn jreleaser:config and check the values of all URLs found under the release.gitlab block?

aalmiray commented 3 years ago

Cannot reproduce. A pom.xml with the following configuration:

      <plugin>
        <groupId>org.jreleaser</groupId>
        <artifactId>jreleaser-maven-plugin</artifactId>
        <version>0.5.0</version>
        <configuration>
            <jreleaser>
                <release>
                    <gitlab>
                        <host>custom.gitlab.com</host>
                    </gitlab>
                </release>
                <announce>
                    <slack>
                        <active>ALWAYS</active>
                    </slack>
                </announce>
            </jreleaser>
        </configuration>
      </plugin>

Invoking mvn jreleaser:announce and inspecting target/jreleaser/trace.log shows the custom GitLab host used in releaseNotesUrl

[INFO]    [slack] channel: #announce
[DEBUG]   [slack] Slack dryrun set to true
[DEBUG]   [slack] slack.message: Message[channel='#announce', content='๐Ÿš€ App 1.0.0 has been released! https://custom.gitlab.com/aalmiray/app/-/releases/v1.0.0']

UPDATE: the error occurs with JReleaser 0.4.0 but does not with 0.5.0. Please upgrade at your earliest convenience.