ExportXMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor
    • Component/s: jira-steps-plugin
    • None
    • Environment:
      jira-steps-plugin 2.1.197.vdd1b_3987e040
      Jenkins 2.580.1 LTS
      Java: Eclipse Temurin 25.0.4
      OS: Ubuntu 24.04 (Linux controller)
      Jira: Jira Cloud (atlassian.net)

      When auditLog is true (the default), jiraAddComment appends this panel to every comment. Example for a build started by Jenkins user "noyon":

      {panel}Automatically created by: [~noyon] from [Build URL|https://jenkins.example.com/job/release-pipeline/42/]{panel}
      

      On Jira Server / Data Center, the [~noyon] mention is resolved by username. On Jira Cloud it must be an Atlassian accountId (for example 557058:f58131cb-b67d-43c7-b30d-6b58d40bd077). The plugin uses the Jenkins user ID from UserIdCause verbatim (JiraStepExecution.prepareBuildUserId() and addPanelMeta()). That value is never a valid accountId, so Jira Cloud renders the mention as @unknown and the comment cannot be traced back to the user who triggered the build.

      Steps to reproduce:

      1. Configure a Jira site named "jira-cloud" in Jenkins pointing at a Jira Cloud instance (https://example.atlassian.net).
      2. As the logged-in Jenkins user "noyon", run a pipeline containing:
        jiraAddComment idOrKey: 'TEST-1', comment: 'hello', site: 'jira-cloud'
        
      3. Open TEST-1 in Jira Cloud and look at the new comment.

      Expected: "Automatically created by" links to the Jira user who triggered the build, or shows plain-text attribution if no matching Jira user exists.
      Actual: the mention is shown as @unknown.

      Proposed fix: https://github.com/jenkinsci/jira-steps-plugin/pull/289
      Before building the mention, look up the user with GET /rest/api/2/user/search?query=noyon and choose the mention format from the result:

      Single match with accountId (Jira Cloud)       -> [~accountid:557058:f58131cb-b67d-43c7-b30d-6b58d40bd077]
      Single match with name (Jira Server / DC)      -> [~noyon]   (unchanged behaviour)
      No match or multiple matches                   -> Automatically created by: noyon   (plain text, no broken mention)
      Lookup fails (older Server without ?query=)    -> [~noyon]   (previous behaviour)
      

      The result is cached per step execution, so there is only one API call per build. Validated end-to-end on a live Jira Cloud instance.

            Assignee:
            Md Mohaymenul
            Reporter:
            Md Mohaymenul
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: