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

Plugin fails to add comment on JIRA issue even if it adds link to JIRA issue on "Changes" tab in Jenkins #395

Open
xalbillos opened this issue Dec 17, 2021 · 8 comments

Comments

@xalbillos
Copy link

Hi,

I have followed these steps:

  1. Under Jenkins > Manage Jenkins > Jira, I have configured the plugin and used the "Validate Settings" button. It returns "Success".
  2. Then, I have tried with a freestyle project and added a post-build action "Jira: Update relevant issues" and selected "Explicit selector". Then, added a specific ticket. Running that freestyle project job adds a comment on the related JIRA ticket. Everything fine until now.
  3. I have configured the JIRA plugin inside a multi-branch pipeline. I have set the "issue pattern" to blank, to make sure I don't fail the regular expression and it uses the default one. I have checked the "Update Relevant Jira Issues For All Build Results" checkbox. After building from a commit that includes a JIRA ticket in the commit message, I go to the "Changes" tab of that build and see the JIRA ticket becomes a link to JIRA. I understand this means the plugin understands the ticket pattern and connects with our JIRA to form the URL. But on the JIRA ticket this run by the multi-branch pipeline branch doesn't add a comment to the JIRA ticket.

How can I troubleshoot this and see what's happening and what could be wrong ?
Thanks a lot for your help !

@rantoniuk
Copy link
Contributor

What do you see in the build logs?

@xalbillos
Copy link
Author

@rantoniuk
I don't see any logs from the plugin, no error, no nothing. Is there a way to activate a verbose mode ?

@shaishap
Copy link

This issue happens for us as well.
I don't see any error in the log. Once in the log, I did see the
org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{'
error, but I no longer see it.
It simply does nothing to the jira issue.
We use jira datacenter version 8.20.0, and jira-plugin 3.7.1

@rantoniuk
Copy link
Contributor

Can you share your Jenkinsfile?

@segor
Copy link

segor commented Jul 2, 2024

@rantoniuk,
We have got the same issue in our multi-branch pipeline. We do not see any errors or warnings in the System and build logs which would help to diagnose the issue. But there are 3 records appear many times the System logs:

Jul 02, 2024 11:14:34 AM FINE hudson.plugins.jira.JiraChangeLogAnnotator
Using site: https://jira.xxx.com/
Jul 02, 2024 11:14:34 AM FINE hudson.plugins.jira.JiraChangeLogAnnotator
Using issue pattern: ([a-zA-Z][a-zA-Z0-9_]+-[1-9][0-9]*)([^.]|\.[^0-9]|\.$|$)
Jul 02, 2024 11:14:34 AM FINE hudson.plugins.jira.JiraChangeLogAnnotator
Annotating Jira id: 'XXX-2437'

It looks like the plugin makes a lot of tries to add a comment but does not log a failure. I see in the line

that not all the possible exceptions are recorded. So for better diagnostic it might be reasonable to record any exception thrown in the saveIssues() or the annotate() methods. Also it would be helpful to write a notification that operation succeeded.

@rantoniuk
Copy link
Contributor

THe IOException is caught and logged. Since you don't see a log entry about it, it means it was not thrown and also no other exception was thrown (or it was somewhere else but caught without proper logging - I agree that exception handling here is not ideal, but it's mostly historical code).

@segor
Copy link

segor commented Jul 2, 2024

@rantoniuk, To make sure there is no unhandled exceptions I propose to wrap code in the annotate() method:

public void annotate(Run<?, ?> run, Entry change, MarkupText text) {
  try {
  //....
  } catch (Exception e) {
    LOGGER.log(Level.WARNING, "Error annotating of change log", e);
    throw e;
}

Otherwise I do not see any way to find the cause of this issue.
If you agree with this, I could prepare a PR.

@rantoniuk
Copy link
Contributor

No PR needed is needed yet - just change the code, compile and run the custom plugin on your instance to see if you can find the root cause.

You can build your custom plugin with mvn clean package and then install the target/xx-SNAPSHOT.hpi file as described here.

Make as many changes as you need to find the root cause, then:

  1. create a PR with appropriate logging updates
  2. let us know in here what is the root cause

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants