Add support for newlines in custom hook messages to be shown in the UI

XMLWordPrintable

    • Type: Suggestion
    • Resolution: Unresolved
    • None
    • Component/s: UI
    • None
    • 0
    • 1

      Newlines in custom hook messages are currently not shown in pop up messages

      Sample steps to illustrate the current behaviour:

      1. Launch a Bitbucket instance
      2. Install the plugin Adaptavist ScriptRunner for Bitbucket Server
      3. in Administration > ScriptRunner, go to "Pre Hooks"
      4. Create a "Custom Pre Hook" script and set the trigger to "branch-delete"
      5. Use the following script to throw a popup message during branch deletion
        import com.atlassian.bitbucket.hook.repository.RepositoryHookResult
        
        RepositoryHookResult.rejected("Branch delete", "First line" + "\nSecond line"+ "\r\nThird line" + "\r\n\r\nFourth Line")
        

        In this sample script, newlines were added

      6. Locate a repository and delete a branch from the UI

      The newlines in the custom message are not shown and are being removed:

      The JSON response from the DELETE <BITBUCKET_URL>/rest/branch-utils/latest/projects/<PROJECT_KEY>/repos/<REPO_SLUG>/branches request shows the following:

      {
          "errors":
          [
              {
                  "context": null,
                  "message": "Branch 'test-branch' could not be deleted",
                  "exceptionName": "com.atlassian.bitbucket.hook.repository.RepositoryHookVetoedException",
                  "details":
                  [
                      "Branch delete\nFirst line\n\nSecond line\r\nThird line\r\n\r\nFourth Line"
                  ],
                  "trigger":
                  {
                      "id": "branch-delete",
                      "abortOnFirstVeto": false
                  }
              }
          ]
      }
      

      The "details" includes the newline chars (e.g. "\n")

      But the newlines are removed in the pop up message (highlighted in green):

        1. custom-popup-message.png
          522 kB
          JP Mariano
        2. custom-popup-message-inspector.png
          631 kB
          JP Mariano

              Assignee:
              Unassigned
              Reporter:
              JP Mariano
              Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: